#NEWLINE# def eval_loss_and_grads( self , x ) : #NEWLINE# #INDENT# x = x . reshape ( self . output_shape ) #NEWLINE# outs = self . f_outputs ( [ x ] ) #NEWLINE# loss_value = outs [ 0 ] #NEWLINE# if ( len ( outs [ 1 : ] ) == 1 ) : #NEWLINE# #INDENT# grad_values = outs [ 1 ] . flatten ( ) . astype ( 'float64' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# grad_values = np . array ( outs [ 1 : ] ) . flatten ( ) . astype ( 'float64' ) #NEWLINE# #UNINDENT# return ( loss_value , loss_value )