#NEWLINE# def test_gradient( self ) : #NEWLINE# #INDENT# '\n        Testing to see whether the gradient can be calculated.\n        ' #NEWLINE# rnn = RNN ( input_space = SequenceSpace ( VectorSpace ( dim = 1 ) ) , layers = [ Recurrent ( dim = 2 , layer_name = 'recurrent' , irange = 0 , nonlinearity = ( lambda x : x ) ) , Linear ( dim = 1 , layer_name = 'linear' , irange = 0 ) ] ) #NEWLINE# ( X_data , X_mask ) = rnn . get_input_space ( ) . make_theano_batch ( ) #NEWLINE# ( y_data , y_mask ) = rnn . get_output_space ( ) . make_theano_batch ( ) #NEWLINE# default_cost = Default ( ) #NEWLINE# cost = default_cost . expr ( rnn , ( ( X_data , self ) , ( y_data , y_mask ) ) ) #NEWLINE# tensor . grad ( cost , rnn . get_params ( ) , disconnected_inputs = 'ignore' )