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)
After Change
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