36093633b630d0934dae5b9abbda83d775f0e845,trainer/trainer.py,Trainer,_valid_epoch,#Trainer#,85

Before Change


            total_val_loss += loss.data[0]

            for i, metric in enumerate(self.metrics):
                y_output = output.data.cpu().numpy()
                y_output = np.argmax(y_output, axis=1)
                y_target = target.data.cpu().numpy()
                total_val_metrics[i] += metric(y_output, y_target)

        avg_val_loss = total_val_loss / len(self.valid_data_loader)

After Change


            total_val_loss += loss.data[0]
            total_val_metrics += self._eval_metrics(output, target)

        return {
            "val_loss": total_val_loss / len(self.valid_data_loader), 
            "val_metrics": (total_val_metrics / len(self.valid_data_loader)).tolist()
        }
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: victoresque/pytorch-template
Commit Name: 36093633b630d0934dae5b9abbda83d775f0e845
Time: 2018-04-18
Author: vichuang1997@gmail.com
File Name: trainer/trainer.py
Class Name: Trainer
Method Name: _valid_epoch


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 64171b3cdf5f0fca6bb11e48831946db63263684
Time: 2020-02-06
Author: killian.levacher@gmail.com
File Name: tests/attacks/evasion/test_fast_gradient.py
Class Name:
Method Name: test_minimal_perturbations_images


Project Name: victoresque/pytorch-template
Commit Name: 36093633b630d0934dae5b9abbda83d775f0e845
Time: 2018-04-18
Author: vichuang1997@gmail.com
File Name: trainer/trainer.py
Class Name: Trainer
Method Name: _train_epoch