1__author__ = 'Thomas Rueckstiess, ruecksti@in.tum.de'
2
3from pybrain.structure.modules.neuronlayer import NeuronLayer
4
5class SoftSignLayer(NeuronLayer):
6    """ softsign activation function as described in X. Glorot and Y.
7        Bengio. Understanding the difficulty of training deep feedforward neural
8        networks. In Proceedings of the 13th International Workshop on
9        Artificial Intelligence and Statistics, 2010. """
10
11    def _forwardImplementation(self, inbuf, outbuf):
12        outbuf[:] = inbuf / (1 + abs(inbuf))
13
14    def _backwardImplementation(self, outerr, inerr, outbuf, inbuf):
15        inerr[:] = (1 - abs(outbuf))**2 * outerr
16