add cosine activation

This commit is contained in:
Connor Olding 2017-06-09 12:32:44 +00:00
parent d3c23912c1
commit 7e38f45a3f

View file

@ -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):