#NEWLINE# @ pytest . mark . parametrize ( 'activation, expected' , [ ( 'linear' , PROBE ) , ( 'logistic' , ( 1 / ( 1 + np . exp ( ( - PROBE ) ) ) ) ) , ( 'sigmoid' , ( 1 / ( 1 + np . exp ( ( - PROBE ) ) ) ) ) , ( 'softmax' , ( np . exp ( PROBE ) / sum ( np . exp ( PROBE ) ) ) ) , ( 'softplus' , np . log1p ( np . exp ( PROBE ) ) ) , ( 'relu' , np . clip ( PROBE , 0 , 100 ) ) , ( 'rect:max' , np . clip ( PROBE , 0 , 100 ) ) , ( 'rect:min' , np . clip ( PROBE , ( - 100 ) , 1 ) ) , ( 'rect:minmax' , np . clip ( np . clip ( PROBE , 0 , 100 ) , ( - 100 ) , 1 ) ) , ( 'norm:mean' , ( PROBE - PROBE . mean ( ) ) ) , ( 'norm:max' , ( PROBE / abs ( PROBE ) . max ( ) ) ) , ( 'norm:std' , ( PROBE / PROBE . std ( ) ) ) , ( 'norm:z' , ( ( PROBE - PROBE . mean ( ) ) / PROBE . std ( ) ) ) , ( 'prelu' , np . array ( [ ( - 0.71239 ) , ( - 0.0753766 ) , ( - 0.0004450307 ) , 0 , 0.1 , 1 , 10 ] , 'f' ) ) , ( 'lgrelu' , np . array ( [ ( - 0.8612113 ) , ( - 0.1478685 ) , ( - 0.0104537 ) , 0 , 0.013451 , 0.0532337 , 1.350188 ] , 'f' ) ) , ( 'maxout:3' , np . array ( [ 8.31461 , ( - 0.59702 ) , 1.31311 , 1.89274 , 0.6057 , 1.38634 , 6.16415 ] , 'f' ) ) , ( 'relu+tanh' , np . tanh ( np . clip ( PROBE , 0 , 100 ) ) ) , ( 'softplus+norm:z' , ( ( np . log1p ( np . exp ( PROBE ) ) - np . log1p ( np . exp ( PROBE ) ) . mean ( ) ) / np . log1p ( np . exp ( PROBE ) ) . std ( ) ) ) ] ) #NEWLINE# def test_activation( activation , expected ) : #NEWLINE# #INDENT# layer = theanets . layers . Feedforward ( inputs = 'x' , size = 7 , rng = 13 ) #NEWLINE# f = theanets . activations . build ( activation , layer ) #NEWLINE# actual = f ( theano . shared ( PROBE ) ) #NEWLINE# if hasattr ( activation , 'eval' ) : #NEWLINE# #INDENT# actual = actual . eval ( ) #NEWLINE# #UNINDENT# assert np . allclose ( actual , expected )