#NEWLINE# def test_max_pool( ) : #NEWLINE# #INDENT# '\n    Test max pooling for known result.\n    ' #NEWLINE# X_sym = tensor . tensor4 ( 'X' ) #NEWLINE# pool_it = max_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# X = np . array ( [ [ 2 , 1 , 3 , 4 ] , [ 1 , 1 , 3 , 3 ] , [ 5 , 5 , 7 , 7 ] , [ 5 , 6 , 8 , 7 ] , [ 9 , 10 , 11 , 12 ] , [ 9 , 10 , 12 , 12 ] ] , dtype = theano . config . floatX ) [ ( np . newaxis , np . newaxis , ... ) ] #NEWLINE# expected = np . array ( [ [ 2 , 4 ] , [ 6 , 8 ] , [ 10 , 12 ] ] , dtype = theano . config . floatX ) [ ( np . newaxis , np . newaxis , ... ) ] #NEWLINE# actual = f ( X ) #NEWLINE# assert np . allclose ( expected , actual )