102123eef25500a39160412eca7e8cb9f53104a6,trainer/trainer.py,Trainer,_train_epoch,#Trainer#Any#,36
Before Change
self.model.train()
total_loss = 0
total_metrics = np.zeros(len(self.metrics))
for batch_idx, (data, target) in enumerate(self.data_loader):
data, target = data.to(self.device), target.to(self.device)
self.optimizer.zero_grad()
output = self.model(data)
loss = self.criterion(output, target)
loss.backward()
self.optimizer.step()
self.writer.set_step((epoch - 1) * self.len_epoch + batch_idx)
self.writer.add_scalar("loss", loss.item())
total_loss += loss.item()
total_metrics += self._eval_metrics(output, target)
if batch_idx % self.log_step == 0:
self.logger.debug("Train Epoch: {} {} Loss: {:.6f}".format(
epoch,
After Change
if self.do_validation:
val_log = self._valid_epoch(epoch)
log.update(**{"val_"+k : v for k, v in val_log.items()})
if self.lr_scheduler is not None:
self.lr_scheduler.step()
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: victoresque/pytorch-template
Commit Name: 102123eef25500a39160412eca7e8cb9f53104a6
Time: 2019-09-10
Author: SunQ0313@gmail.com
File Name: trainer/trainer.py
Class Name: Trainer
Method Name: _train_epoch
Project Name: PIQuIL/QuCumber
Commit Name: 364948bf0bb46f9bc3809bbe0a63d09348994444
Time: 2018-08-04
Author: emerali@users.noreply.github.com
File Name: qucumber/complex_wavefunction.py
Class Name: ComplexWavefunction
Method Name: __init__
Project Name: NifTK/NiftyNet
Commit Name: 3e403dd963698ff77cac54cf8f38c3dbaa0de046
Time: 2017-08-06
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/engine/sampler_uniform.py
Class Name: UniformSampler
Method Name: layer_op