#NEWLINE# def test_elemwise2( ) : #NEWLINE# #INDENT# ' Several kinds of elemwise expressions with dimension permutations ' #NEWLINE# rng = numpy . random . RandomState ( int ( time . time ( ) ) ) #NEWLINE# shape = ( 3 , 5 ) #NEWLINE# for pattern in [ ( 0 , 1 ) , ( 1 , 0 ) ] : #NEWLINE# #INDENT# a = tcn . shared_constructor ( theano . _asarray ( rng . rand ( * shape ) , dtype = 'float32' ) , name = None ) #NEWLINE# b = tensor . Tensor ( dtype = 'float32' , broadcastable = ( [ 0 ] * len ( shape ) ) ) ( ) #NEWLINE# f = pfunc ( [ b ] , [ ] , updates = [ ( a , ( a + b ) . dimshuffle ( pattern ) ) ] , mode = mode_with_gpu ) #NEWLINE# has_elemwise = False #NEWLINE# for ( i , node ) in enumerate ( f . maker . fgraph . toposort ( ) ) : #NEWLINE# #INDENT# has_elemwise = ( has_elemwise or isinstance ( node . op , tensor . Elemwise ) ) #NEWLINE# #UNINDENT# assert ( not has_elemwise ) #NEWLINE# f ( ( theano . _asarray ( rng . rand ( * shape ) , dtype = 'float32' ) * 0.3 ) ) #NEWLINE# #UNINDENT# shape = ( 3 , 4 , 5 , 6 ) #NEWLINE# a = tcn . shared_constructor ( theano . _asarray ( rng . rand ( * shape ) , dtype = 'float32' ) , 'a' ) #NEWLINE# b = tensor . Tensor ( dtype = 'float32' , broadcastable = ( [ 0 ] * len ( shape ) ) ) ( ) #NEWLINE# f = pfunc ( [ b ] , [ ] , updates = [ ( pattern , ( ( a + b ) . dimshuffle ( [ 2 , 0 , 3 , 1 ] ) * tensor . exp ( ( b ** a ) ) . dimshuffle ( [ 2 , 0 , 3 , 1 ] ) ) ) ] , mode = mode_with_gpu ) #NEWLINE# has_elemwise = False #NEWLINE# for ( i , node ) in enumerate ( f . maker . fgraph . toposort ( ) ) : #NEWLINE# #INDENT# has_elemwise = ( has_elemwise or isinstance ( node . op , tensor . Elemwise ) ) #NEWLINE# #UNINDENT# assert ( not has_elemwise ) #NEWLINE# f ( theano . _asarray ( rng . rand ( * shape ) , dtype = 'float32' ) )