From 7e38f45a3f1ef13d5b2f4ea89bcd3cda69ee5e9f Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 9 Jun 2017 12:32:44 +0000 Subject: [PATCH] add cosine activation --- optim_nn_core.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/optim_nn_core.py b/optim_nn_core.py index feba346..179389a 100644 --- a/optim_nn_core.py +++ b/optim_nn_core.py @@ -672,6 +672,16 @@ class LogSoftmax(Softmax): def backward(self, dY): return dY - np.sum(dY, axis=-1, keepdims=True) * self.sm +class Cos(Layer): + # performs well on MNIST for some strange reason. + + def forward(self, X): + self.X = X + return np.cos(X) + + def backward(self, dY): + return dY * -np.sin(self.X) + # Parametric Layers {{{1 class Dense(Layer):