4d3ea76dcab0d44a9a58a2482cada4b7d5386726,neuron/layers.py,MeanStream,call,#MeanStream#Any#,512

Before Change


        pre_mean = self.mean
    
        // compute this batch stats
        this_sum = tf.reduce_sum(x, 0)
        this_bs = tf.cast(K.shape(x)[0], "float32")  // this batch size
        
        // increase count and compute weights
        new_count = self.count + this_bs
        alpha = this_bs/K.minimum(new_count, self.cap)
        
        // compute new mean. Note that once we reach self.cap (e.g. 1000), the "previous mean" matters less
        new_mean = pre_mean * (1-alpha) + (this_sum/this_bs) * alpha
        
        updates = [(self.count, new_count), (self.mean, new_mean)]
        self.add_update(updates, x)
        

After Change


        self.add_update(updates, x)

        // prep for broadcasting :(
        p = tf.concat((K.reshape(this_bs_int, (1,)), K.shape(self.mean)), 0)
        z = K.ones(p)
        
        // the first few 1000 should not matter that much towards this cost
        return K.minimum(1., new_count/self.cap) * (z * K.expand_dims(new_mean, 0))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: adalca/neuron
Commit Name: 4d3ea76dcab0d44a9a58a2482cada4b7d5386726
Time: 2019-03-07
Author: adalca@mit.edu
File Name: neuron/layers.py
Class Name: MeanStream
Method Name: call


Project Name: deepchem/deepchem
Commit Name: a437991e12a334b40b082fdc8b1b6dcf4a68021f
Time: 2017-04-17
Author: bharath.ramsundar@gmail.com
File Name: deepchem/models/tensorgraph/layers.py
Class Name: NeighborList
Method Name: get_cells_for_atoms


Project Name: deepchem/deepchem
Commit Name: a437991e12a334b40b082fdc8b1b6dcf4a68021f
Time: 2017-04-17
Author: bharath.ramsundar@gmail.com
File Name: deepchem/models/tensorgraph/layers.py
Class Name: NeighborList
Method Name: get_neighbor_cells