#NEWLINE# def test_elemwise_composite_support_code( ) : #NEWLINE# #INDENT# '\n    This was generating an error at compile time.\n    Commit 3d1690fa346103594356ecaeceeb2c6757b45d2b fixed that.\n    ' #NEWLINE# X = tcn . shared_constructor ( value = numpy . zeros ( ( 100 , 10 ) , dtype = 'float32' ) , name = 'X' ) #NEWLINE# W = tcn . shared_constructor ( value = numpy . zeros ( ( 10 , 1 ) , dtype = 'float32' ) , name = 'W' ) #NEWLINE# U = T . dot ( X , W ) #NEWLINE# Y = tcn . shared_constructor ( value = numpy . zeros ( ( 100 , 1 ) , dtype = 'float32' ) , name = 'Y' ) #NEWLINE# P = T . exp ( ( - ( ( Y - U ) ** 2 ) ) ) #NEWLINE# epsilon = numpy . asarray ( 0.001 , dtype = 'float32' ) #NEWLINE# NLL = ( - T . mean ( T . log ( ( P + epsilon ) ) ) ) #NEWLINE# G = theano . gradient . grad ( NLL , wrt = [ W ] ) #NEWLINE# backup = theano . config . warn . identify_1pexp_bug #NEWLINE# theano . config . warn . identify_1pexp_bug = False #NEWLINE# try : #NEWLINE# #INDENT# f_grad = theano . function ( inputs = [ ] , outputs = G , mode = mode_with_gpu ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# theano . config . warn . identify_1pexp_bug = backup #NEWLINE# #UNINDENT# f_grad ( ) #NEWLINE# topo = f_grad . maker . fgraph . toposort ( ) #NEWLINE# assert ( sum ( [ isinstance ( node . op , T . Elemwise ) for node in topo ] ) == 1 ) #NEWLINE# assert ( sum ( [ isinstance ( node . op , tcn . GpuElemwise ) for node in topo ] ) == 1 )