fb5b85e7f4c9af0190019ea8a8bcaa3e4a1e6d6b,torchsample/constraints.py,UnitNorm,__call__,#UnitNorm#Any#,83

Before Change


        if self.lagrangian:
            w = module.weight
            norm = th.norm(w, 2, 1)
            return self.scale * th.sum(th.clamp(norm-1,0,1e15))
        else:
            w = module.weight
           // w.div_(th.norm(w, 2, 1).expand_as(w))

After Change


        if self.lagrangian:
            w = module.weight
            norm_diff = th.norm(w, 2, 1).sub(1.)
            return self.scale * th.sum(norm_diff.gt(0).float().mul(norm_diff))
        else:
            w = module.weight
            w = w.div(th.norm(w,2,1).expand_as(w))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: ncullen93/torchsample
Commit Name: fb5b85e7f4c9af0190019ea8a8bcaa3e4a1e6d6b
Time: 2017-05-01
Author: ncullen@Nicks-MacBook-Pro.local
File Name: torchsample/constraints.py
Class Name: UnitNorm
Method Name: __call__


Project Name: ncullen93/torchsample
Commit Name: fb5b85e7f4c9af0190019ea8a8bcaa3e4a1e6d6b
Time: 2017-05-01
Author: ncullen@Nicks-MacBook-Pro.local
File Name: torchsample/constraints.py
Class Name: MaxNorm
Method Name: __call__


Project Name: ncullen93/torchsample
Commit Name: fb5b85e7f4c9af0190019ea8a8bcaa3e4a1e6d6b
Time: 2017-05-01
Author: ncullen@Nicks-MacBook-Pro.local
File Name: torchsample/constraints.py
Class Name: NonNeg
Method Name: __call__