#NEWLINE# def test_perform_sigm_times_exp( self ) : #NEWLINE# #INDENT# '\n        Test the core function doing the `sigm_times_exp` optimization.\n\n        It is easier to test different graph scenarios this way than by\n        compiling a theano function.\n        ' #NEWLINE# ( x , y , z , t ) = tensor . vectors ( 'x' , 'y' , 'z' , 't' ) #NEWLINE# exp = tensor . exp #NEWLINE# def ok( expr1 , expr2 ) : #NEWLINE# #INDENT# trees = [ parse_mul_tree ( e ) for e in ( expr1 , expr2 ) ] #NEWLINE# perform_sigm_times_exp ( trees [ 0 ] ) #NEWLINE# trees [ 0 ] = simplify_mul ( trees [ 0 ] ) #NEWLINE# good = theano . gof . graph . is_same_graph ( compute_mul ( trees [ 0 ] ) , compute_mul ( trees [ 1 ] ) ) #NEWLINE# if ( not good ) : #NEWLINE# #INDENT# print ( trees [ 0 ] ) #NEWLINE# print ( trees [ 1 ] ) #NEWLINE# print ( '***' ) #NEWLINE# theano . printing . debugprint ( compute_mul ( trees [ 0 ] ) ) #NEWLINE# print ( '***' ) #NEWLINE# theano . printing . debugprint ( compute_mul ( trees [ 1 ] ) ) #NEWLINE# #UNINDENT# assert good #NEWLINE# #UNINDENT# ok ( ( sigmoid ( x ) * exp ( ( - x ) ) ) , sigmoid ( ( - x ) ) ) #NEWLINE# ok ( ( ( ( - x ) * sigmoid ( x ) ) * ( ( y * ( ( - 1 ) * z ) ) * exp ( ( - x ) ) ) ) , ( ( ( - x ) * sigmoid ( ( - x ) ) ) * ( y * ( ( - 1 ) * z ) ) ) ) #NEWLINE# ok ( ( ( ( - sigmoid ( ( - x ) ) ) * ( ( exp ( y ) * ( ( ( - exp ( ( - z ) ) ) * 3 ) * ( - exp ( x ) ) ) ) * ( ( ( y * 2 ) * ( ( ( - sigmoid ( ( - y ) ) ) * ( z + t ) ) * exp ( z ) ) ) * sigmoid ( z ) ) ) ) * ( - sigmoid ( x ) ) ) , ( ( sigmoid ( x ) * ( ( ( - sigmoid ( y ) ) * ( ( - sigmoid ( ( - z ) ) ) * 3 ) ) * ( ( y * 2 ) * ( ( z + t ) * exp ( z ) ) ) ) ) * ( - sigmoid ( x ) ) ) ) #NEWLINE# ok ( ( ( exp ( ( - x ) ) * ( - exp ( ( - x ) ) ) ) * ( ( - sigmoid ( x ) ) * ( - sigmoid ( x ) ) ) ) , ( ( - sigmoid ( ( - x ) ) ) * sigmoid ( ( - x ) ) ) ) #NEWLINE# ok ( ( ( ( - exp ( x ) ) * ( - sigmoid ( ( - x ) ) ) ) * ( - exp ( ( - x ) ) ) ) , ( - sigmoid ( ( - x ) ) ) )