115a1c5f642c0285afc46d0b49eafb4b192a0afa,train.py,,train_model,#Any#Any#Any#Any#Any#,142

Before Change


                running_corrects += torch.sum(preds == labels.data)

            epoch_loss = running_loss / dataset_sizes[phase]
            if int(version[2]) > 3: // for the new version like 0.4.0 and 0.5.0
                running_corrects = running_corrects.item()
            epoch_acc = running_corrects / dataset_sizes[phase]
            
            print("{} Loss: {:.4f} Acc: {:.4f}".format(
                phase, epoch_loss, epoch_acc))

After Change


                    running_loss += loss.item()
                else :  // for the old version like 0.3.0 and 0.3.1
                    running_loss += loss.data[0]
                running_corrects += float(torch.sum(preds == labels.data))

            epoch_loss = running_loss / dataset_sizes[phase]
            epoch_acc = running_corrects / dataset_sizes[phase]
            
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: layumi/Person_reID_baseline_pytorch
Commit Name: 115a1c5f642c0285afc46d0b49eafb4b192a0afa
Time: 2018-07-10
Author: Zhedong.Zheng@student.uts.edu.au
File Name: train.py
Class Name:
Method Name: train_model


Project Name: allenai/allennlp
Commit Name: ed322ebaf136955b8f9f060d8fc49a6c252a0bba
Time: 2021-01-20
Author: epwalsh10@gmail.com
File Name: allennlp/training/metrics/average.py
Class Name: Average
Method Name: __call__


Project Name: pytorch/fairseq
Commit Name: 5028ed1b6bedd526dee27ea731284f43e87303f0
Time: 2020-03-11
Author: myleott@fb.com
File Name: fairseq/trainer.py
Class Name: Trainer
Method Name: train_step