#NEWLINE# def test_nested_grad_1( ) : #NEWLINE# #INDENT# npr . seed ( 10 ) #NEWLINE# for ii in xrange ( NUM_TRIALS ) : #NEWLINE# #INDENT# npX = npr . randn ( 10 , 20 ) #NEWLINE# X = kayak . Parameter ( npX ) #NEWLINE# Y = kayak . MatSum ( Z , axis = 0 ) #NEWLINE# Z = kayak . MatSum ( Y ) #NEWLINE# assert ( Z . grad ( X ) . shape == npX . shape ) #NEWLINE# assert np . all ( close_float ( Z . grad ( X ) , np . ones ( npX . shape ) ) ) #NEWLINE# assert ( kayak . util . checkgrad ( X , Z ) < MAX_GRAD_DIFF )