b8b71c4fbab9bd9e6a34a18a65474cc1035699de,thinc/neural/ops.py,Ops,softmax,#Ops#Any#Any#Any#,84

Before Change


                "Softmax currently only supports 2d. ndim=%d" % x.ndim)
        shape = x.shape
        new_x = self.xp.zeros(shape=shape, dtype="f")
        for i in range(shape[0]):
            new_x[i] = self.xp.exp(x[i] - self.xp.max(x[i]))
            new_x[i] /= new_x[i].sum()
        if inplace:
            x[:] = new_x
            return x
        else:

After Change


            raise NotImplementedError(
                "Softmax currently only supports 2d. ndim=%d" % x.ndim)
        shape = x.shape
        maxes = self.xp.max(x, axis=1)
        maxes = maxes.reshape((x.shape[0], 1))
        shifted = x - maxes
        new_x = self.xp.exp(shifted)
        new_x /= new_x.sum(axis=1).reshape((x.shape[0], 1))
        if inplace:
            x[:] = new_x
            return x
        else:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: explosion/thinc
Commit Name: b8b71c4fbab9bd9e6a34a18a65474cc1035699de
Time: 2017-01-07
Author: honnibal+gh@gmail.com
File Name: thinc/neural/ops.py
Class Name: Ops
Method Name: softmax


Project Name: lmcinnes/umap
Commit Name: a434c63df31f3b7d25f77da7c64e32f86d5230dd
Time: 2017-12-08
Author: leland.mcinnes@gmail.com
File Name: umap/umap_.py
Class Name:
Method Name: fuzzy_simplicial_set


Project Name: dpressel/mead-baseline
Commit Name: 9d519c382c261166cc26ff66500d2d8eb8fc85fb
Time: 2018-06-29
Author: blester125@users.noreply.github.com
File Name: python/baseline/pytorch/torchy.py
Class Name: CRF
Method Name: decode


Project Name: explosion/thinc
Commit Name: b8b71c4fbab9bd9e6a34a18a65474cc1035699de
Time: 2017-01-07
Author: honnibal+gh@gmail.com
File Name: thinc/neural/ops.py
Class Name: Ops
Method Name: softmax