e15bc113b83c2bdf980d2557971888d10011ef29,neuralstyle/transformernet.py,InstanceNormalization,forward,#InstanceNormalization#Any#,117

Before Change


        t = x.resize(x.size()[0], x.size()[1], 1, n)
        mean = torch.mean(t, 3).repeat(1, 1, x.size()[2], x.size()[3])
        // Calculate the biased var. torch.var returns unbiased var
        var = torch.var(t, 3).repeat(1, 1, x.size()[2], x.size()[3]) * ((n - 1) / float(n))
        res = (x - mean) / torch.sqrt(var + 1e-5)
        // TODO: Check if you need to add scaling and shifting here
        return res

After Change


        mean = torch.mean(t, 3).expand_as(x)
        // Calculate the biased var. torch.var returns unbiased var
        var = torch.var(t, 3).expand_as(x)
        scale_broadcast = self.scale.unsqueeze(1).unsqueeze(1).unsqueeze(0)
        scale_broadcast = scale_broadcast.expand_as(x)
        shift_broadcast = self.shift.unsqueeze(1).unsqueeze(1).unsqueeze(0)
        shift_broadcast = shift_broadcast.expand_as(x)
        out = (x - mean) / torch.sqrt(var + 1e-5)
        out = (out * scale_broadcast) + shift_broadcast
        return out
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: abhiskk/fast-neural-style
Commit Name: e15bc113b83c2bdf980d2557971888d10011ef29
Time: 2017-03-14
Author: abhishekkadiyan@gmail.com
File Name: neuralstyle/transformernet.py
Class Name: InstanceNormalization
Method Name: forward


Project Name: OpenNMT/OpenNMT-py
Commit Name: ba164c0dbb3d8171004380956a88431f4e8248ba
Time: 2017-08-01
Author: bpeters@coli.uni-saarland.de
File Name: onmt/Models.py
Class Name: Embeddings
Method Name: make_positional_encodings


Project Name: maciejkula/spotlight
Commit Name: 70e4d7fe60a9658bb27b9f5fb67592a1222b2ec3
Time: 2017-07-06
Author: maciej.kula@gmail.com
File Name: spotlight/sequence/representations.py
Class Name: PoolNet
Method Name: user_representation