#NEWLINE# def test_nn_operations( self ) : #NEWLINE# #INDENT# check_single_tensor_operation ( 'relu' , ( 4 , 2 ) , alpha = 0.1 , max_value = 0.5 ) #NEWLINE# check_single_tensor_operation ( 'softmax' , ( 4 , 10 ) ) #NEWLINE# check_single_tensor_operation ( 'softplus' , ( 4 , 10 ) ) #NEWLINE# check_single_tensor_operation ( 'sigmoid' , ( 4 , 2 ) ) #NEWLINE# check_single_tensor_operation ( 'hard_sigmoid' , ( 4 , 2 ) ) #NEWLINE# check_single_tensor_operation ( 'tanh' , ( 4 , 2 ) ) #NEWLINE# val = np . random . random ( ( 100 , 100 ) ) #NEWLINE# xth = KTH . variable ( val ) #NEWLINE# xtf = KTF . variable ( self ) #NEWLINE# zth = KTH . eval ( KTH . dropout ( xth , level = 0.2 ) ) #NEWLINE# ztf = KTF . eval ( KTF . dropout ( xtf , level = 0.2 ) ) #NEWLINE# assert ( zth . shape == ztf . shape ) #NEWLINE# assert ( np . abs ( ( zth . mean ( ) - ztf . mean ( ) ) ) < 0.05 ) #NEWLINE# check_two_tensor_operation ( 'binary_crossentropy' , ( 4 , 2 ) , ( 4 , 2 ) , from_logits = True ) #NEWLINE# check_two_tensor_operation ( 'categorical_crossentropy' , ( 4 , 2 ) , ( 4 , 2 ) , from_logits = True ) #NEWLINE# check_two_tensor_operation ( 'binary_crossentropy' , ( 4 , 2 ) , ( 4 , 2 ) , from_logits = False ) #NEWLINE# check_two_tensor_operation ( 'categorical_crossentropy' , ( 4 , 2 ) , ( 4 , 2 ) , from_logits = False ) #NEWLINE# check_single_tensor_operation ( 'l2_normalize' , ( 4 , 3 ) , axis = ( - 1 ) ) #NEWLINE# check_single_tensor_operation ( 'l2_normalize' , ( 4 , 3 ) , axis = 1 )