#NEWLINE# def test_AveragePoolPaddingStride_grad_grad( self ) : #NEWLINE# #INDENT# rng = numpy . random . RandomState ( utt . fetch_seed ( ) ) #NEWLINE# imgsizes = ( ( 10 , 10 ) , ( 10 , 5 ) , ( 5 , 5 ) ) #NEWLINE# avgpoolsizes = ( ( 5 , 3 ) , ( 3 , 5 ) , ( 3 , 3 ) ) #NEWLINE# stridesizes = ( ( 3 , 2 ) , ( 2 , 3 ) , ( 3 , 3 ) ) #NEWLINE# paddingsizes = ( ( 2 , 2 ) , ( 2 , 1 ) , ( 2 , 2 ) ) #NEWLINE# for i in range ( len ( imgsizes ) ) : #NEWLINE# #INDENT# imgsize = imgsizes [ i ] #NEWLINE# imval = ( rng . rand ( 1 , 1 , imgsize [ 0 ] , imgsize [ 1 ] ) * 10.0 ) #NEWLINE# avgpoolsize = avgpoolsizes [ i ] #NEWLINE# stridesize = stridesizes [ i ] #NEWLINE# paddingsize = paddingsizes [ i ] #NEWLINE# for mode in [ 'sum' , 'average_inc_pad' ] : #NEWLINE# #INDENT# grad_shape = Pool . out_shape ( imval . shape , avgpoolsize , st = stridesize , ignore_border = True , padding = paddingsize ) #NEWLINE# grad_val = ( rng . rand ( * grad_shape ) * 10.0 ) #NEWLINE# def mp( input , grad ) : #NEWLINE# #INDENT# grad_op = AveragePoolGrad ( avgpoolsize , ignore_border = True , st = stridesize , padding = paddingsize , mode = mode ) #NEWLINE# return grad_op ( input , grad ) #NEWLINE# #UNINDENT# utt . verify_grad ( mp , [ imval , grad_val ] , rng = rng )