343819f93523ae4f25bd1e9ee192af74cf6962ee,fairseq/trainer.py,Trainer,_get_grads,#Trainer#,268

Before Change


        for name, p in self.model.named_parameters():
            if not p.requires_grad:
                continue
            if p.grad is None:
                raise RuntimeError("Model parameter did not receive gradient: " + name + ". "
                                   "Use the param in the forward pass or set requires_grad=False")
            grads.append(p.grad.data)
        return grads

    def _get_flat_grads(self, out=None):

After Change


        for name, p in self.model.named_parameters():
            if not p.requires_grad:
                continue
            if p.grad is None:
                print("WARNING: model parameter did not receive gradient: " + name + ". "
                      "Check that you\"re using the param in the forward pass or set requires_grad=False")
                grads.append(p.new_zeros(p.shape))
            else:
                grads.append(p.grad.data)
        return grads

    def _get_flat_grads(self, out=None):
        grads = self._get_grads()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: elbayadm/attn2d
Commit Name: 343819f93523ae4f25bd1e9ee192af74cf6962ee
Time: 2018-09-03
Author: alexei.b@gmail.com
File Name: fairseq/trainer.py
Class Name: Trainer
Method Name: _get_grads


Project Name: pytorch/fairseq
Commit Name: 343819f93523ae4f25bd1e9ee192af74cf6962ee
Time: 2018-09-03
Author: alexei.b@gmail.com
File Name: fairseq/trainer.py
Class Name: Trainer
Method Name: _get_grads


Project Name: dmlc/gluon-cv
Commit Name: fdd55d36c05c747643fc98430a7f9b787b6cec16
Time: 2019-08-29
Author: yizhu59@gmail.com
File Name: gluoncv/data/kinetics400/classification.py
Class Name: Kinetics400
Method Name: _TSN_RGB