#NEWLINE# def test_DownsampleFactorMaxStrideExtra( self ) : #NEWLINE# #INDENT# rng = numpy . random . RandomState ( utt . fetch_seed ( ) ) #NEWLINE# maxpoolshps = ( ( 5 , 3 ) , ( 5 , 3 ) , ( 5 , 3 ) , ( 5 , 5 ) , ( 3 , 2 ) , ( 7 , 7 ) , ( 9 , 9 ) ) #NEWLINE# stridesizes = ( ( 3 , 2 ) , ( 7 , 5 ) , ( 10 , 6 ) , ( 1 , 1 ) , ( 2 , 3 ) , ( 10 , 10 ) , ( 1 , 1 ) ) #NEWLINE# imvsizs = ( ( 16 , 16 ) , ( 16 , 16 ) , ( 16 , 16 ) , ( 8 , 5 ) , ( 8 , 5 ) , ( 8 , 5 ) , ( 8 , 5 ) ) #NEWLINE# outputshps = ( ( 4 , 10 , 4 , 7 ) , ( 4 , 10 , 5 , 8 ) , ( 4 , 10 , 2 , 3 ) , ( 4 , 10 , 3 , 4 ) , ( 4 , 10 , 2 , 3 ) , ( 4 , 10 , 2 , 3 ) , ( 4 , 10 , 4 , 1 ) , ( 4 , 10 , 4 , 1 ) , ( 4 , 10 , 3 , 2 ) , ( 4 , 10 , 4 , 2 ) , ( 4 , 10 , 1 , 0 ) , ( 4 , 10 , 1 , 1 ) , ( 4 , 10 , 0 , 0 ) , ( 4 , 10 , 1 , 1 ) ) #NEWLINE# images = tensor . dtensor4 ( ) #NEWLINE# for indx in numpy . arange ( len ( maxpoolshps ) ) : #NEWLINE# #INDENT# imvsize = imvsizs [ indx ] #NEWLINE# imval = rng . rand ( 4 , 10 , imvsize [ 0 ] , imvsize [ 1 ] ) #NEWLINE# stride = stridesizes [ indx ] #NEWLINE# maxpoolshp = maxpoolshps [ indx ] #NEWLINE# for ( ignore_border , mode ) in product ( [ True , False ] , [ 'max' , 'sum' , 'average_inc_pad' , 'average_exc_pad' ] ) : #NEWLINE# #INDENT# indx_out = ( indx * 2 ) #NEWLINE# if ( not ignore_border ) : #NEWLINE# #INDENT# indx_out += 1 #NEWLINE# #UNINDENT# outputshp = outputshps [ indx_out ] #NEWLINE# numpy_output_val = self . numpy_max_pool_2d_stride ( imval , maxpoolshp , stridesizes , stride , mode ) #NEWLINE# assert ( numpy_output_val . shape == outputshp ) , ( 'outshape is %s, calculated shape is %s' % ( outputshp , numpy_output_val . shape ) ) #NEWLINE# maxpool_op = Pool ( maxpoolshp , ignore_border = ignore_border , st = stride , mode = mode ) ( images ) #NEWLINE# f = function ( [ images ] , maxpool_op ) #NEWLINE# output_val = f ( imval ) #NEWLINE# utt . assert_allclose ( output_val , numpy_output_val )