Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
23
def
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_entropy
Function · 0.70
Calls
2
exp
Method · 0.45
sum
Method · 0.45
Tested by
no test coverage detected