50c88091cbb82591db49f5328de8069d6d464bc7,base/base_trainer.py,BaseTrainer,__init__,#BaseTrainer#Any#Any#Any#Any#Any#Any#Any#,15

Before Change


        self.logger = logging.getLogger(self.__class__.__name__)

        // setup GPU device if available, move model into configured device
        self.with_cuda = config["cuda"] and torch.cuda.is_available()
        if config["cuda"] and not torch.cuda.is_available():
            self.logger.warning("Warning: There\"s no GPU available on this machine, "
                                "training will be performed on CPU.")
        self.device = torch.device("cuda:" + str(config["gpu"]) if self.with_cuda else "cpu")
        self.model = model.to(self.device)

        self.loss = loss

After Change


            self.logger.warning("Warning: There\"s no GPU available on this machine, training will be performed on CPU.")
            n_gpu_use = 0
        if n_gpu_use > n_gpu:
            msg = "Warning: The number of GPU\"s configured to use is {}, but only {} are available on this machine.".format(n_gpu_use, n_gpu)
            self.logger.warning(msg)
            n_gpu_use = n_gpu
        self.device = torch.device("cuda:0" if n_gpu_use > 0 else "cpu")
        self.model = model.to(self.device)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: victoresque/pytorch-template
Commit Name: 50c88091cbb82591db49f5328de8069d6d464bc7
Time: 2018-10-02
Author: sunq0313@gmail.com
File Name: base/base_trainer.py
Class Name: BaseTrainer
Method Name: __init__


Project Name: pymanopt/pymanopt
Commit Name: 618c1cac7908e5aa61fd95e0d1c6c1f31a2db95d
Time: 2016-02-19
Author: niklas.koep@gmail.com
File Name: pymanopt/core/problem.py
Class Name: Problem
Method Name: backend


Project Name: tristandeleu/pytorch-maml-rl
Commit Name: efd31f17f6753ee92ef1038016bd9470f25867d1
Time: 2019-12-08
Author: tristan.deleu@gmail.com
File Name: train.py
Class Name:
Method Name: