#NEWLINE# def check_forward( self , x_data , use_cudnn = True ) : #NEWLINE# #INDENT# x = chainer . Variable ( x_data ) #NEWLINE# y = functions . max_pooling_2d ( use_cudnn , 3 , stride = 2 , pad = 1 , cover_all = self . cover_all , use_cudnn = use_cudnn ) #NEWLINE# self . assertEqual ( y . data . dtype , numpy . float32 ) #NEWLINE# y_data = cuda . to_cpu ( y . data ) #NEWLINE# self . assertEqual ( self . gy . shape , y_data . shape ) #NEWLINE# for k in six . moves . range ( 2 ) : #NEWLINE# #INDENT# for c in six . moves . range ( 3 ) : #NEWLINE# #INDENT# if self . cover_all : #NEWLINE# #INDENT# expect = numpy . array ( [ [ self . x [ k , c , 0 : 2 , 0 : 2 ] . max ( ) , self . x [ k , c , 0 : 2 , 1 : 3 ] . max ( ) ] , [ self . x [ k , c , 1 : 4 , 0 : 2 ] . max ( ) , self . x [ k , c , 1 : 4 , 1 : 3 ] . max ( ) ] , [ self . x [ k , c , 3 : 4 , 0 : 2 ] . max ( ) , self . x [ k , c , 3 : 4 , 1 : 3 ] . max ( ) ] ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# expect = numpy . array ( [ [ self . x [ k , c , 0 : 2 , 0 : 2 ] . max ( ) , self . x [ k , c , 0 : 2 , 1 : 3 ] . max ( ) ] , [ self . x [ k , c , 1 : 4 , 0 : 2 ] . max ( ) , self . x [ k , c , 1 : 4 , 1 : 3 ] . max ( ) ] ] ) #NEWLINE# #UNINDENT# gradient_check . assert_allclose ( expect , y_data [ ( k , c ) ] )