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

Before Change


        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


            n_gpu_use = n_gpu
        self.device = torch.device("cuda:0" if n_gpu_use > 0 else "cpu")
        self.model = model.to(self.device)
        if n_gpu_use > 1:
            self.model = torch.nn.DataParallel(model, device_ids=list(range(n_gpu_use)))

        self.loss = loss
        self.metrics = metrics
        self.optimizer = optimizer
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

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: junyanz/pytorch-CycleGAN-and-pix2pix
Commit Name: 212abd8f1113e9eabf5248078acc54021d02268e
Time: 2018-04-18
Author: junyanzhu89@gmail.com
File Name: models/networks.py
Class Name:
Method Name: define_D