4b0134242f0e79bcdb022623be29e1e7db5445fc,examples/scripts/ray_parallel.py,DataWorker,compute_gradients,#DataWorker#Any#,45

Before Change


            data, target = next(self.data_iterator)
        self.model.zero_grad()
        output = self.model(data)
        loss = F.nll_loss(output, target)
        loss.backward()
        return self.model.get_gradients()

After Change


            data, target = next(self.data_iterator)
        
        guesses, backprop = self.model(data, is_train=True)
        backprop((guesses - target) / target.shape[0])
        return get_model_grads(self.model)

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: explosion/thinc
Commit Name: 4b0134242f0e79bcdb022623be29e1e7db5445fc
Time: 2020-01-04
Author: honnibal+gh@gmail.com
File Name: examples/scripts/ray_parallel.py
Class Name: DataWorker
Method Name: compute_gradients


Project Name: pytorch/fairseq
Commit Name: e73fddf45377e8a3c0ea2e8281fae18f7b498dd6
Time: 2018-03-05
Author: myleott@fb.com
File Name: fairseq/criterions/label_smoothed_cross_entropy.py
Class Name: LabelSmoothedCrossEntropyCriterion
Method Name: forward