MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / softmax

Function softmax

imperative/python/test/unit/functional/test_loss.py:24–27  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

22
23def test_cross_entropy():
24 def softmax(x):
25 x = np.exp(x)
26 x /= x.sum(1, keepdims=True)
27 return x
28
29 def ref(x, y):
30 return np.mean([-np.log(x[i, y[i]]) for i in range(len(y))])

Callers 1

test_cross_entropyFunction · 0.70

Calls 2

expMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected