Softmax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class softmax(Operation):
"""Returns the softmax of a.
"""
def __init__(self, a):
"""Construct softmax
Args:
a: Input node
"""
super().__init__([a])
def compute(self, a_value):
"""Compute the output of the softmax operation
Args:
a_value: Input value
"""
return np.exp(a_value) / np.sum(np.exp(a_value), axis=1)[:, None]
Enter to Rename, Shift+Enter to Preview