afc71e321e8e849d27e9d3b2f053c9ead11fd171,thinc/neural/vecs2vec.py,MeanPooling,predict,#MeanPooling#Any#,6

Before Change


class MeanPooling(Model):
    name = "mean-pool"
    def predict(self, X):
        means = []
        for x in X:
            means.append(x.mean(axis=0))
        return self.ops.asarray(means)

    def begin_update(self, X, drop=0.0):
        X, bp_dropout = self.ops.dropout(X, drop)
        def finish_update(gradient, sgd=None):

After Change


class MeanPooling(Model):
    name = "mean-pool"
    def predict(self, seqs):
        X = self.ops.xp.vstack(seqs)
        lengths = [len(seq) for seq in seqs]
        means = self.ops.allocate((len(lengths), X.shape[1]))
        start = 0
        for i, length in enumerate(lengths):
            end = start + length
            means[i] = X[start : end].mean(axis=0)
            start = end
        assert means.shape == (len(seqs), seqs[0].shape[1])
        return means

    def begin_update(self, seqs, drop=0.0):
        X = self.ops.xp.vstack(seqs)
        lengths = [len(seq) for seq in seqs]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 13

Instances


Project Name: explosion/thinc
Commit Name: afc71e321e8e849d27e9d3b2f053c9ead11fd171
Time: 2017-02-04
Author: honnibal@gmail.com
File Name: thinc/neural/vecs2vec.py
Class Name: MeanPooling
Method Name: predict


Project Name: ContextLab/hypertools
Commit Name: 1430ab58648b4bd189f232ae2acc8b86ce2fd9aa
Time: 2016-12-17
Author: andrew.heusser@gmail.com
File Name: python/hypertools/reduce.py
Class Name:
Method Name: reducePCA


Project Name: ContextLab/hypertools
Commit Name: ab4c3743ec1c77d67ddede9fb400b55b3778e39b
Time: 2016-12-17
Author: andrew.heusser@gmail.com
File Name: python/hypertools/reduce.py
Class Name:
Method Name: reducePCA