61aad8f9cda61b833dc7ed2b4e45e68236aae943,fairseq/optim/fairseq_optimizer.py,FairseqOptimizer,clip_grad_norm,#FairseqOptimizer#Any#,87

Before Change


    def clip_grad_norm(self, max_norm):
        Clips gradient norm.
        if max_norm > 0:
            return torch.nn.utils.clip_grad_norm_(self.params, max_norm)
        else:
            return torch.sqrt(sum(p.grad.data.norm()**2 for p in self.params if p.grad is not None))

    def step(self, closure=None):

After Change



    def clip_grad_norm(self, max_norm):
        Clips gradient norm.
        return utils.clip_grad_norm_(self.params, max_norm)

    def step(self, closure=None):
        Performs a single optimization step.
        self.optimizer.step(closure)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: pytorch/fairseq
Commit Name: 61aad8f9cda61b833dc7ed2b4e45e68236aae943
Time: 2020-01-28
Author: myleott@fb.com
File Name: fairseq/optim/fairseq_optimizer.py
Class Name: FairseqOptimizer
Method Name: clip_grad_norm


Project Name: facebookresearch/pytext
Commit Name: 1ea44daf7b99b68fc09c78c95ce36c75bdef95cb
Time: 2019-06-11
Author: chenyangyu@instagram.com
File Name: pytext/utils/precision.py
Class Name:
Method Name: clip_grad_norm