#NEWLINE# def test_mean_pool( ) : #NEWLINE# #INDENT# X_sym = tensor . tensor4 ( 'X' ) #NEWLINE# pool_it = mean_pool ( X_sym , pool_shape = ( 2 , 2 ) , pool_stride = ( 2 , 2 ) , image_shape = ( 6 , 4 ) ) #NEWLINE# f = theano . function ( inputs = [ X_sym ] , outputs = pool_it ) #NEWLINE# t = np . array ( [ [ 1 , 1 , 3 , 3 ] , [ 1 , 1 , 3 , 3 ] , [ 5 , 5 , 7 , 7 ] , [ 5 , 5 , 7 , 7 ] , [ 9 , 9 , 11 , 11 ] , [ 9 , 9 , 11 , 11 ] ] , dtype = theano . config . floatX ) #NEWLINE# X = np . zeros ( ( 3 , t . shape [ 0 ] , t . shape [ 1 ] ) , dtype = theano . config . floatX ) #NEWLINE# X [ : ] = t #NEWLINE# X = X [ np . newaxis ] #NEWLINE# expected = np . array ( [ [ 1 , 3 ] , [ 5 , 7 ] , [ 9 , 11 ] ] , dtype = theano . config . floatX ) #NEWLINE# actual = f ( X ) #NEWLINE# assert np . allclose ( expected , actual ) #NEWLINE# t = np . array ( [ [ 0 , 1 , 3 , 2 ] , [ 1 , 2 , 4 , 3 ] , [ 4 , 6 , 7 , 7 ] , [ 5 , 5 , 6 , 8 ] , [ 8 , 10 , 11 , 11 ] , [ 9 , 9 , 10 , 12 ] ] , dtype = theano . config . floatX ) #NEWLINE# X = np . zeros ( ( 3 , t . shape [ 0 ] , t . shape [ 1 ] ) , dtype = theano . config . floatX ) #NEWLINE# X [ : ] = t #NEWLINE# X = X [ np . newaxis ] #NEWLINE# expected = np . array ( [ [ 1 , 3 ] , [ 5 , 7 ] , [ 9 , 11 ] ] , dtype = theano . config . floatX ) #NEWLINE# actual = f ( X ) #NEWLINE# assert np . allclose ( expected , actual )