def test_max_pool():
 X_sym = tensor.tensor4('X')
 pool_it = max_pool(X_sym, pool_shape=(2, 2), pool_stride=(2, 2), image_shape=(6, 4))
 f = theano.function(inputs=[X_sym], outputs=pool_it)
 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, ...]
 expected = np.array([[2, 4], [6, 8], [10, 12]], dtype=theano.config.floatX)[np.newaxis, np.newaxis, ...]
 actual = f(X)
 assert np.allclose(expected, actual)

def test_max_pool ( ) : X_sym = tensor . tensor4 ( 'X' ) pool_it = max_pool ( X_sym , pool_shape = ( 2 , 2 ) , pool_stride = ( 2 , 2 ) , image_shape = ( 6 , 4 ) ) f = theano . function ( inputs = [ X_sym ] , outputs = pool_it ) 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 , ... ] expected = np . array ( [ [ 2 , 4 ] , [ 6 , 8 ] , [ 10 , 12 ] ] , dtype = theano . config . floatX ) [ np . newaxis , np . newaxis , ... ] actual = f ( X ) assert np . allclose ( expected , actual )
test max pooling for known result .