Additional modification to softmax
This commit is contained in:
parent
5769d7c1f0
commit
d48cb9214c
@ -155,7 +155,7 @@ class CrossEntropySoftmaxError(object):
|
|||||||
Scalar error function value.
|
Scalar error function value.
|
||||||
"""
|
"""
|
||||||
normOutputs = outputs - outputs.max(-1)[:, None]
|
normOutputs = outputs - outputs.max(-1)[:, None]
|
||||||
logProb = normOutputs - np.log(np.sum(np.exp(normOutputs)))
|
logProb = normOutputs - np.log(np.sum(np.exp(normOutputs), axis=-1)[:, None])
|
||||||
return -np.mean(np.sum(targets * logProb, axis=1))
|
return -np.mean(np.sum(targets * logProb, axis=1))
|
||||||
|
|
||||||
def grad(self, outputs, targets):
|
def grad(self, outputs, targets):
|
||||||
|
Loading…
Reference in New Issue
Block a user