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.")

After Change


        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: 4

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: ruotianluo/ImageCaptioning.pytorch
Commit Name: ff3cfae418fc645b35c745752845dff28061a69a
Time: 2017-10-25
Author: rluo@ttic.edu
File Name: train.py
Class Name:
Method Name: train