#NEWLINE# def check_correctness( f ) : #NEWLINE# #INDENT# rng = np . random . RandomState ( [ 2012 , 7 , 19 ] ) #NEWLINE# batch_size = 5 #NEWLINE# rows = 32 #NEWLINE# cols = 30 #NEWLINE# channels = 3 #NEWLINE# pool_rows = 2 #NEWLINE# pool_cols = 3 #NEWLINE# zv = ( ( rng . randn ( batch_size , rows , cols , channels ) . astype ( config . floatX ) * 2.0 ) - 3.0 ) #NEWLINE# ( p_np , h_np ) = max_pool_python ( zv , ( pool_rows , pool_cols ) ) #NEWLINE# z_th = T . TensorType ( broadcastable = ( False , False , False , False ) , dtype = config . floatX ) ( ) #NEWLINE# z_th . name = 'z_th' #NEWLINE# ( p_th , h_th ) = f ( z_th , ( pool_rows , pool_cols ) ) #NEWLINE# func = function ( [ z_th ] , [ p_th , h_th ] ) #NEWLINE# ( pv , hv ) = func ( zv ) #NEWLINE# assert ( p_np . shape == pv . shape ) #NEWLINE# assert ( h_np . shape == hv . shape ) #NEWLINE# if ( not np . allclose ( h_np , hv ) ) : #NEWLINE# #INDENT# print ( ( h_np . min ( ) , h_np . max ( ) ) ) #NEWLINE# print ( ( hv . min ( ) , hv . max ( ) ) ) #NEWLINE# assert False #NEWLINE# #UNINDENT# assert np . allclose ( p_np , pv )