#NEWLINE# def check_numerical_grad_one( self , f , df , xs , gys , eps ) : #NEWLINE# #INDENT# dfxs = df ( xs ) #NEWLINE# gys = tuple ( ( ( 0 if ( gy is None ) else gy ) for gy in gys ) ) #NEWLINE# dx_expect = tuple ( map ( ( lambda dfx : _dot ( dfx , gys ) ) , dfxs ) ) #NEWLINE# def func( ) : #NEWLINE# #INDENT# return f ( xs ) #NEWLINE# #UNINDENT# dx_actual = gradient_check . numerical_grad ( func , xs , gys , eps ) #NEWLINE# print ( 'eps: {}' . format ( eps ) ) #NEWLINE# self . assertEqual ( len ( dx_expect ) , len ( dx_actual ) ) #NEWLINE# for ( e , a ) in zip ( dx_expect , dx_actual ) : #NEWLINE# #INDENT# gradient_check . assert_allclose ( e , a , atol = 0.001 , rtol = 0.001 )