70b15bde1d8a1b29d24f23bac1a28a63be0fb4d2,torchsample/modules/super_module.py,SuperModule,evaluate_loader,#SuperModule#Any#,223

Before Change



    def evaluate_loader(self, loader):
        nb_batches = int(math.ceil(len(loader.dataset.inputs)/loader.batch_size))
        losses = torch.FloatTensor(nb_batches)
        for batch_idx, (x_batch, y_batch) in enumerate(loader):
            x_batch = Variable(x_batch)
            y_batch = Variable(y_batch)

            y_pred = self(x_batch)
            loss = self._loss(y_pred, y_batch)
            losses[batch_idx] = loss.data[0]

        return torch.mean(losses)

    def save(self, file):
        
        Save a model to disk

After Change



            y_pred = self(x_batch)
            loss = self._loss(y_pred, y_batch)
            total_loss += loss.data[0]*len(x_batch)
            total_samples += len(x_batch)
        self.train()
        return total_loss / total_samples

    def evaluate_on_batch(self, x, y):
        self.eval()
        x = Variable(x)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: ncullen93/torchsample
Commit Name: 70b15bde1d8a1b29d24f23bac1a28a63be0fb4d2
Time: 2017-04-20
Author: ncullen@modv-vlan533.0018.apn.wlan.med.upenn.edu
File Name: torchsample/modules/super_module.py
Class Name: SuperModule
Method Name: evaluate_loader


Project Name: allenai/allennlp
Commit Name: 8ba58675175e91d306f55380833458acfcb38cdd
Time: 2018-05-10
Author: pradeep.dasigi@gmail.com
File Name: allennlp/models/semantic_parsing/wikitables/wikitables_erm_semantic_parser.py
Class Name: WikiTablesErmSemanticParser
Method Name: _get_state_cost


Project Name: HsinYingLee/DRIT
Commit Name: fad73753f836de5cdd08d8e23d26c1170d19b386
Time: 2018-04-09
Author: hytseng0509@gmail.com
File Name: src/dataset_unpair.py
Class Name: dataset_unpair
Method Name: __getitem__