From 5769d7c1f0e2a47849d2f59802a26e0d8d4cf9a7 Mon Sep 17 00:00:00 2001 From: AntreasAntoniou Date: Tue, 14 Nov 2017 14:56:11 +0000 Subject: [PATCH] Fixed stable softmax --- mlp/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlp/errors.py b/mlp/errors.py index 0b0d603..a141784 100644 --- a/mlp/errors.py +++ b/mlp/errors.py @@ -155,7 +155,7 @@ class CrossEntropySoftmaxError(object): Scalar error function value. """ normOutputs = outputs - outputs.max(-1)[:, None] - logProb = normOutputs - np.log(np.sum(np.exp(normOutputs))(-1)[:, None]) + logProb = normOutputs - np.log(np.sum(np.exp(normOutputs))) return -np.mean(np.sum(targets * logProb, axis=1)) def grad(self, outputs, targets):