RecurrentLayer Class Reference

This class represents a recurrent layer of neurons. More...

#include <recurrent_layer.h>

Inheritance diagram for RecurrentLayer:
Layer

Public Types

enum class  ActivationFunction {
  Threshold , SymmetricThreshold , Logistic , HyperbolicTangent ,
  Linear , RectifiedLinear , ExponentialLinear , ScaledExponentialLinear ,
  SoftPlus , SoftSign , HardSigmoid
}
 Enumeration of the available activation functions for the recurrent layer. More...
 
- Public Types inherited from Layer
enum class  Type {
  Scaling , Convolutional , Perceptron , Pooling ,
  Probabilistic , LongShortTermMemory , Recurrent , Unscaling ,
  Bounding
}
 This enumeration represents the possible types of layers. More...
 

Public Member Functions

 RecurrentLayer ()
 
 RecurrentLayer (const Index &, const Index &)
 
virtual ~RecurrentLayer ()
 
bool is_empty () const
 
Index get_inputs_number () const
 Returns the number of inputs to the layer. More...
 
Index get_neurons_number () const
 Returns the size of the neurons vector. More...
 
const Tensor< type, 1 > & get_hidden_states () const
 Returns the hidden states of the layer. More...
 
Index get_timesteps () const
 
Tensor< type, 1 > get_biases () const
 
const Tensor< type, 2 > & get_input_weights () const
 
const Tensor< type, 2 > & get_recurrent_weights () const
 
Index get_biases_number () const
 
Index get_input_weights_number () const
 
Index get_recurrent_weights_number () const
 
Index get_parameters_number () const
 Returns the number of parameters (biases and weights) of the layer. More...
 
Tensor< type, 1 > get_parameters () const
 
Tensor< type, 2 > get_biases (const Tensor< type, 1 > &) const
 
Tensor< type, 2 > get_input_weights (const Tensor< type, 1 > &) const
 
Tensor< type, 2 > get_recurrent_weights (const Tensor< type, 1 > &) const
 
const RecurrentLayer::ActivationFunctionget_activation_function () const
 Returns the activation function of the layer. More...
 
string write_activation_function () const
 
const bool & get_display () const
 
void set ()
 
void set (const Index &, const Index &)
 
void set (const RecurrentLayer &)
 
void set_default ()
 
void set_inputs_number (const Index &)
 
void set_neurons_number (const Index &)
 
void set_input_shape (const Tensor< Index, 1 > &)
 
void set_timesteps (const Index &)
 
void set_biases (const Tensor< type, 1 > &)
 
void set_input_weights (const Tensor< type, 2 > &)
 
void set_recurrent_weights (const Tensor< type, 2 > &)
 
void set_parameters (const Tensor< type, 1 > &, const Index &=0)
 
void set_activation_function (const ActivationFunction &)
 
void set_activation_function (const string &)
 
void set_display (const bool &)
 
void set_hidden_states_constant (const type &)
 
void set_biases_constant (const type &)
 
void set_input_weights_constant (const type &)
 
void set_recurrent_weights_constant (const type &)
 
void initialize_input_weights_Glorot (const type &, const type &)
 
void set_parameters_constant (const type &)
 
void set_parameters_random ()
 
void calculate_combinations (const Tensor< type, 1 > &, const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void calculate_activations (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void calculate_activations_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
Tensor< type, 2 > calculate_outputs (const Tensor< type, 2 > &)
 
void forward_propagate (const Tensor< type, 2 > &, LayerForwardPropagation *)
 
void forward_propagate (const Tensor< type, 2 > &, const Tensor< type, 1 >, LayerForwardPropagation *)
 
void calculate_hidden_delta (LayerForwardPropagation *, LayerBackPropagation *, LayerForwardPropagation *, LayerBackPropagation *) const
 
void calculate_hidden_delta_perceptron (PerceptronLayerForwardPropagation *, PerceptronLayerBackPropagation *, RecurrentLayerBackPropagation *) const
 
void calculate_hidden_delta_probabilistic (ProbabilisticLayerForwardPropagation *, ProbabilisticLayerBackPropagation *, RecurrentLayerBackPropagation *) const
 
void insert_gradient (LayerBackPropagation *, const Index &, Tensor< type, 1 > &) const
 
void calculate_error_gradient (const Tensor< type, 2 > &, LayerForwardPropagation *, LayerBackPropagation *) const
 
void calculate_biases_error_gradient (const Tensor< type, 2 > &, RecurrentLayerForwardPropagation *, RecurrentLayerBackPropagation *) const
 
void calculate_input_weights_error_gradient (const Tensor< type, 2 > &, RecurrentLayerForwardPropagation *, RecurrentLayerBackPropagation *) const
 
void calculate_recurrent_weights_error_gradient (const Tensor< type, 2 > &, RecurrentLayerForwardPropagation *, RecurrentLayerBackPropagation *) const
 
string write_expression (const Tensor< string, 1 > &, const Tensor< string, 1 > &) const
 
string write_activation_function_expression () const
 
string write_expression_python () const
 
string write_combinations_python () const
 
string write_activations_python () const
 
void from_XML (const tinyxml2::XMLDocument &)
 
void write_XML (tinyxml2::XMLPrinter &) const
 
- Public Member Functions inherited from Layer
string get_name () const
 
void set_threads_number (const int &)
 
virtual Tensor< type, 2 > calculate_outputs_from4D (const Tensor< type, 4 > &)
 
virtual Tensor< type, 4 > calculate_outputs_4d (const Tensor< type, 4 > &)
 
virtual void forward_propagate (const Tensor< type, 4 > &, LayerForwardPropagation *)
 
virtual void forward_propagate (const Tensor< type, 4 > &, Tensor< type, 1 >, LayerForwardPropagation *)
 
virtual void calculate_hidden_delta_lm (LayerForwardPropagation *, LayerBackPropagationLM *, LayerBackPropagationLM *) const
 
virtual void calculate_error_gradient (const Tensor< type, 4 > &, LayerForwardPropagation *, LayerBackPropagation *) const
 
virtual void calculate_squared_errors_Jacobian_lm (const Tensor< type, 2 > &, LayerForwardPropagation *, LayerBackPropagationLM *)
 
virtual void insert_squared_errors_Jacobian_lm (LayerBackPropagationLM *, const Index &, Tensor< type, 2 > &) const
 
virtual Index get_synaptic_weights_number () const
 Returns the number of layer's synaptic weights. More...
 
Type get_type () const
 
string get_type_string () const
 Takes the type of layer used by the model. More...
 
virtual string write_expression_c () const
 

Protected Attributes

Index timesteps = 1
 
Tensor< type, 1 > biases
 
Tensor< type, 2 > input_weights
 
Tensor< type, 2 > recurrent_weights
 This matrix containing conection strengths from a recurrent layer inputs to its neurons. More...
 
ActivationFunction activation_function = ActivationFunction::HyperbolicTangent
 Activation function variable. More...
 
Tensor< type, 1 > hidden_states
 
bool display = true
 Display messages to screen. More...
 
- Protected Attributes inherited from Layer
ThreadPool * thread_pool = nullptr
 
ThreadPoolDevice * thread_pool_device = nullptr
 
string layer_name = "layer"
 Layer name. More...
 
Type layer_type = Type::Perceptron
 Layer type. More...
 
const Eigen::array< IndexPair< Index >, 1 > A_BT = {IndexPair<Index>(1, 1)}
 
const Eigen::array< IndexPair< Index >, 1 > AT_B = {IndexPair<Index>(0, 0)}
 
const Eigen::array< IndexPair< Index >, 1 > A_B = {IndexPair<Index>(1, 0)}
 

Additional Inherited Members

- Protected Member Functions inherited from Layer
void hard_sigmoid (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hyperbolic_tangent (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void logistic (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void threshold (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void symmetric_threshold (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void rectified_linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void scaled_exponential_linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_plus (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_sign (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void exponential_linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void softmax (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void binary (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void competitive (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hard_sigmoid_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hyperbolic_tangent_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void logistic_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void threshold_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void symmetric_threshold_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void rectified_linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void scaled_exponential_linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_plus_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_sign_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void exponential_linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hard_sigmoid (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void hyperbolic_tangent (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void logistic (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void threshold (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void symmetric_threshold (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void rectified_linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void scaled_exponential_linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_plus (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_sign (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void exponential_linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void softmax (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void binary (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void competitive (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void hard_sigmoid_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void hyperbolic_tangent_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void logistic_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void threshold_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void symmetric_threshold_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void rectified_linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void scaled_exponential_linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_plus_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_sign_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void exponential_linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void logistic_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 3 > &) const
 
void softmax_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 3 > &) const
 
void linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void logistic (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hyperbolic_tangent (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void threshold (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void symmetric_threshold (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void rectified_linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void scaled_exponential_linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_plus (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_sign (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hard_sigmoid (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void exponential_linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void logistic_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hyperbolic_tangent_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void threshold_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void symmetric_threshold_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void rectified_linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void scaled_exponential_linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_plus_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_sign_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hard_sigmoid_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void exponential_linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 

Detailed Description

This class represents a recurrent layer of neurons.

Layers of neurons will be used to construct multilayer neurons.

Definition at line 45 of file recurrent_layer.h.

Member Enumeration Documentation

◆ ActivationFunction

enum class ActivationFunction
strong

Enumeration of the available activation functions for the recurrent layer.

Definition at line 52 of file recurrent_layer.h.

Constructor & Destructor Documentation

◆ RecurrentLayer() [1/2]

RecurrentLayer ( )
explicit

Default constructor. It creates a empty layer object, with no neurons. This constructor also initializes the rest of class members to their default values.

Definition at line 18 of file recurrent_layer.cpp.

◆ RecurrentLayer() [2/2]

RecurrentLayer ( const Index &  new_inputs_number,
const Index &  new_neurons_number 
)
explicit

Layer architecture constructor. It creates a layer object with given numbers of inputs and neurons. The parameters are initialized at random. This constructor also initializes the rest of class members to their default values.

Parameters
new_inputs_numberNumber of inputs in the layer.
new_neurons_numberNumber of neurons in the layer.

Definition at line 33 of file recurrent_layer.cpp.

◆ ~RecurrentLayer()

~RecurrentLayer ( )
virtual

Destructor. This destructor does not delete any pointer.

Definition at line 44 of file recurrent_layer.cpp.

Member Function Documentation

◆ calculate_activations()

void calculate_activations ( const Tensor< type, 1 > &  combinations_1d,
Tensor< type, 1 > &  activations_1d 
) const

Definition at line 628 of file recurrent_layer.cpp.

◆ calculate_activations_derivatives()

void calculate_activations_derivatives ( const Tensor< type, 1 > &  combinations_1d,
Tensor< type, 1 > &  activations_1d,
Tensor< type, 1 > &  activations_derivatives_1d 
) const

Definition at line 663 of file recurrent_layer.cpp.

◆ calculate_biases_error_gradient()

void calculate_biases_error_gradient ( const Tensor< type, 2 > &  inputs,
RecurrentLayerForwardPropagation forward_propagation,
RecurrentLayerBackPropagation back_propagation 
) const

Definition at line 1021 of file recurrent_layer.cpp.

◆ calculate_combinations()

void calculate_combinations ( const Tensor< type, 1 > &  inputs,
const Tensor< type, 2 > &  input_weights,
const Tensor< type, 2 > &  recurrent_weights,
const Tensor< type, 1 > &  biases,
Tensor< type, 1 > &  combinations 
) const

Definition at line 614 of file recurrent_layer.cpp.

◆ calculate_error_gradient()

void calculate_error_gradient ( const Tensor< type, 2 > &  inputs,
LayerForwardPropagation forward_propagation,
LayerBackPropagation back_propagation 
) const
virtual

Reimplemented from Layer.

Definition at line 1001 of file recurrent_layer.cpp.

◆ calculate_hidden_delta()

void calculate_hidden_delta ( LayerForwardPropagation next_layer_forward_propagation,
LayerBackPropagation next_layer_back_propagation,
LayerForwardPropagation layer_forward_propagation,
LayerBackPropagation layer_back_propagation 
) const
virtual

Reimplemented from Layer.

Definition at line 845 of file recurrent_layer.cpp.

◆ calculate_hidden_delta_perceptron()

void calculate_hidden_delta_perceptron ( PerceptronLayerForwardPropagation next_forward_propagation,
PerceptronLayerBackPropagation next_back_propagation,
RecurrentLayerBackPropagation back_propagation 
) const

Definition at line 888 of file recurrent_layer.cpp.

◆ calculate_hidden_delta_probabilistic()

void calculate_hidden_delta_probabilistic ( ProbabilisticLayerForwardPropagation next_forward_propagation,
ProbabilisticLayerBackPropagation next_back_propagation,
RecurrentLayerBackPropagation back_propagation 
) const

Definition at line 900 of file recurrent_layer.cpp.

◆ calculate_input_weights_error_gradient()

void calculate_input_weights_error_gradient ( const Tensor< type, 2 > &  inputs,
RecurrentLayerForwardPropagation forward_propagation,
RecurrentLayerBackPropagation back_propagation 
) const

Definition at line 1062 of file recurrent_layer.cpp.

◆ calculate_outputs()

Tensor< type, 2 > calculate_outputs ( const Tensor< type, 2 > &  inputs)
virtual

Reimplemented from Layer.

Definition at line 797 of file recurrent_layer.cpp.

◆ calculate_recurrent_weights_error_gradient()

void calculate_recurrent_weights_error_gradient ( const Tensor< type, 2 > &  inputs,
RecurrentLayerForwardPropagation forward_propagation,
RecurrentLayerBackPropagation back_propagation 
) const

Definition at line 1122 of file recurrent_layer.cpp.

◆ forward_propagate() [1/2]

void forward_propagate ( const Tensor< type, 2 > &  inputs,
const Tensor< type, 1 >  parameters,
LayerForwardPropagation forward_propagation 
)
virtual

Reimplemented from Layer.

Definition at line 751 of file recurrent_layer.cpp.

◆ forward_propagate() [2/2]

void forward_propagate ( const Tensor< type, 2 > &  inputs,
LayerForwardPropagation forward_propagation 
)
virtual

Reimplemented from Layer.

Definition at line 714 of file recurrent_layer.cpp.

◆ from_XML()

void from_XML ( const tinyxml2::XMLDocument document)
virtual

Reimplemented from Layer.

Definition at line 1259 of file recurrent_layer.cpp.

◆ get_activation_function()

const RecurrentLayer::ActivationFunction & get_activation_function ( ) const

Returns the activation function of the layer.

Definition at line 174 of file recurrent_layer.cpp.

◆ get_biases() [1/2]

Tensor< type, 1 > get_biases ( ) const

Returns the biases from all the recurrent neurons in the layer. The format is a vector of real values. The size of this vector is the number of neurons in the layer.

Definition at line 94 of file recurrent_layer.cpp.

◆ get_biases() [2/2]

Tensor< type, 2 > get_biases ( const Tensor< type, 1 > &  parameters) const

Returns the biases from all the recurrent in the layer. The format is a vector of real values. The size of this vector is the number of neurons in the layer.

Definition at line 184 of file recurrent_layer.cpp.

◆ get_biases_number()

Index get_biases_number ( ) const

Definition at line 122 of file recurrent_layer.cpp.

◆ get_display()

const bool & get_display ( ) const

Returns true if messages from this class are to be displayed on the screen, or false if messages from this class are not to be displayed on the screen.

Definition at line 279 of file recurrent_layer.cpp.

◆ get_hidden_states()

const Tensor< type, 1 > & get_hidden_states ( ) const

Returns the hidden states of the layer.

Definition at line 67 of file recurrent_layer.cpp.

◆ get_input_weights() [1/2]

const Tensor< type, 2 > & get_input_weights ( ) const

Returns the weights from the recurrent layer. The format is a matrix of real values. The number of rows is the number of neurons in the layer. The number of columns is the number of inputs to the layer.

Definition at line 105 of file recurrent_layer.cpp.

◆ get_input_weights() [2/2]

Tensor< type, 2 > get_input_weights ( const Tensor< type, 1 > &  parameters) const

Returns the weights from the recurrent layer. The format is a matrix of real values. The number of rows is the number of inputs in the layer. The number of columns is the number of neurons to the layer.

Definition at line 204 of file recurrent_layer.cpp.

◆ get_input_weights_number()

Index get_input_weights_number ( ) const

Definition at line 128 of file recurrent_layer.cpp.

◆ get_inputs_number()

Index get_inputs_number ( ) const
virtual

Returns the number of inputs to the layer.

Reimplemented from Layer.

Definition at line 51 of file recurrent_layer.cpp.

◆ get_neurons_number()

Index get_neurons_number ( ) const
virtual

Returns the size of the neurons vector.

Reimplemented from Layer.

Definition at line 59 of file recurrent_layer.cpp.

◆ get_parameters()

Tensor< type, 1 > get_parameters ( ) const
virtual

Returns a single vector with all the layer parameters. The format is a vector of real values. The size is the number of parameters in the layer.

Reimplemented from Layer.

Definition at line 144 of file recurrent_layer.cpp.

◆ get_parameters_number()

Index get_parameters_number ( ) const
virtual

Returns the number of parameters (biases and weights) of the layer.

Reimplemented from Layer.

Definition at line 75 of file recurrent_layer.cpp.

◆ get_recurrent_weights() [1/2]

const Tensor< type, 2 > & get_recurrent_weights ( ) const

Returns the recurrent weights from the recurrent layer. The format is a matrix of real values. The number of rows is the number of neurons in the layer. The number of columns is the number of neurons to the layer.

Definition at line 116 of file recurrent_layer.cpp.

◆ get_recurrent_weights() [2/2]

Tensor< type, 2 > get_recurrent_weights ( const Tensor< type, 1 > &  parameters) const

Returns the recurrent weights from the recurrent layer. The format is a matrix of real values. The number of rows is the number of neurons in the layer. The number of columns is the number of neurons to the layer.

Definition at line 224 of file recurrent_layer.cpp.

◆ get_recurrent_weights_number()

Index get_recurrent_weights_number ( ) const

Definition at line 134 of file recurrent_layer.cpp.

◆ get_timesteps()

Index get_timesteps ( ) const

Definition at line 84 of file recurrent_layer.cpp.

◆ initialize_input_weights_Glorot()

void initialize_input_weights_Glorot ( const type &  ,
const type &   
)
Todo:

Definition at line 556 of file recurrent_layer.cpp.

◆ insert_gradient()

void insert_gradient ( LayerBackPropagation back_propagation,
const Index &  index,
Tensor< type, 1 > &  gradient 
) const
virtual

Reimplemented from Layer.

Definition at line 973 of file recurrent_layer.cpp.

◆ set() [1/3]

void set ( )

Sets an empty layer, wihtout any neuron. It also sets the rest of members to their default values.

Definition at line 288 of file recurrent_layer.cpp.

◆ set() [2/3]

void set ( const Index &  new_inputs_number,
const Index &  new_neurons_number 
)

Sets new numbers of inputs and neurons in the layer. It also sets the rest of members to their default values.

Parameters
new_inputs_numberNumber of inputs.
new_neurons_numberNumber of neuron.

Definition at line 299 of file recurrent_layer.cpp.

◆ set() [3/3]

void set ( const RecurrentLayer other_neuron_layer)

Sets the members of this neuron layer object with those from other neuron layer object.

Parameters
other_neuron_layerRecurrentLayer object to be copied.

Definition at line 320 of file recurrent_layer.cpp.

◆ set_activation_function() [1/2]

void set_activation_function ( const ActivationFunction new_activation_function)

This class sets a new activation(or transfer) function in a single layer.

Parameters
new_activation_functionActivation function for the layer.

Definition at line 438 of file recurrent_layer.cpp.

◆ set_activation_function() [2/2]

void set_activation_function ( const string &  new_activation_function_name)

Sets a new activation(or transfer) function in a single layer. The second argument is a string containing the name of the function("Logistic", "HyperbolicTangent", "Threshold", etc).

Parameters
new_activation_function_nameActivation function for that layer.

Definition at line 448 of file recurrent_layer.cpp.

◆ set_biases()

void set_biases ( const Tensor< type, 1 > &  new_biases)

Definition at line 389 of file recurrent_layer.cpp.

◆ set_biases_constant()

void set_biases_constant ( const type &  value)

Initializes the biases of all the neurons in the layer of neurons with a given value.

Parameters
valueBiases initialization value.

Definition at line 530 of file recurrent_layer.cpp.

◆ set_default()

void set_default ( )

Sets those members not related to the vector of neurons to their default value.

  • Display: True.
  • layer_type: neuron_Layer.
  • trainable: True.

Definition at line 337 of file recurrent_layer.cpp.

◆ set_display()

void set_display ( const bool &  new_display)

Sets a new display value. If it is set to true messages from this class are to be displayed on the screen; if it is set to false messages from this class are not to be displayed on the screen.

Parameters
new_displayDisplay value.

Definition at line 512 of file recurrent_layer.cpp.

◆ set_hidden_states_constant()

void set_hidden_states_constant ( const type &  value)

Initializes the hidden states of in the layer of neurons with a given value.

Parameters
valueHidden states initialization value.

Definition at line 521 of file recurrent_layer.cpp.

◆ set_input_shape()

void set_input_shape ( const Tensor< Index, 1 > &  size)

Definition at line 359 of file recurrent_layer.cpp.

◆ set_input_weights()

void set_input_weights ( const Tensor< type, 2 > &  new_input_weights)

Definition at line 395 of file recurrent_layer.cpp.

◆ set_input_weights_constant()

void set_input_weights_constant ( const type &  value)

Initializes the input weights of all the neurons in the layer of neurons neuron with a given value.

Parameters
valueInput weights initialization value.

Definition at line 539 of file recurrent_layer.cpp.

◆ set_inputs_number()

void set_inputs_number ( const Index &  new_inputs_number)
virtual

Sets a new number of inputs in the layer. The new synaptic weights are initialized at random.

Parameters
new_inputs_numberNumber of layer inputs.

Reimplemented from Layer.

Definition at line 351 of file recurrent_layer.cpp.

◆ set_neurons_number()

void set_neurons_number ( const Index &  new_neurons_number)
virtual

Sets a new number neurons in the layer. All the parameters are also initialized at random.

Parameters
new_neurons_numberNew number of neurons in the layer.

Reimplemented from Layer.

Definition at line 371 of file recurrent_layer.cpp.

◆ set_parameters()

void set_parameters ( const Tensor< type, 1 > &  new_parameters,
const Index &  index = 0 
)
virtual

Sets the parameters of this layer.

Parameters
new_parametersParameters vector for that layer.
indexIndex for this layer.

Reimplemented from Layer.

Definition at line 411 of file recurrent_layer.cpp.

◆ set_parameters_constant()

void set_parameters_constant ( const type &  value)
virtual

Initializes all the biases, input weights and recurrent weights in the neural newtork with a given value.

Parameters
valueParameters initialization value.

Reimplemented from Layer.

Definition at line 565 of file recurrent_layer.cpp.

◆ set_parameters_random()

void set_parameters_random ( )
virtual

Initializes all the biases and input weights in the layer of neurons at random with values comprised between -1 and 1 values.

Reimplemented from Layer.

Definition at line 580 of file recurrent_layer.cpp.

◆ set_recurrent_weights()

void set_recurrent_weights ( const Tensor< type, 2 > &  new_recurrent_weights)

Definition at line 401 of file recurrent_layer.cpp.

◆ set_recurrent_weights_constant()

void set_recurrent_weights_constant ( const type &  value)

Initializes the recurrent weights of all the neurons in the layer of neurons neuron with a given value.

Parameters
valueSynaptic weights initialization value.

Definition at line 548 of file recurrent_layer.cpp.

◆ set_timesteps()

void set_timesteps ( const Index &  new_timesteps)

Definition at line 383 of file recurrent_layer.cpp.

◆ write_activation_function()

string write_activation_function ( ) const

Returns a string with the name of the layer activation function. This can be: Logistic, HyperbolicTangent, Threshold, SymmetricThreshold, Linear, RectifiedLinear, ScaledExponentialLinear.

Definition at line 245 of file recurrent_layer.cpp.

◆ write_activation_function_expression()

string write_activation_function_expression ( ) const

Definition at line 1246 of file recurrent_layer.cpp.

◆ write_activations_python()

string write_activations_python ( ) const
Todo:

Definition at line 1449 of file recurrent_layer.cpp.

◆ write_combinations_python()

string write_combinations_python ( ) const

Definition at line 1417 of file recurrent_layer.cpp.

◆ write_expression()

string write_expression ( const Tensor< string, 1 > &  inputs_names,
const Tensor< string, 1 > &  outputs_names 
) const
virtual

Returns a string with the expression of the inputs-outputs relationship of the layer.

Parameters
inputs_namesVector of strings with the name of the layer inputs.
outputs_namesVector of strings with the name of the layer outputs.
Todo:
Implement method

Reimplemented from Layer.

Definition at line 1189 of file recurrent_layer.cpp.

◆ write_expression_python()

string write_expression_python ( ) const
virtual

Reimplemented from Layer.

Definition at line 1516 of file recurrent_layer.cpp.

◆ write_XML()

void write_XML ( tinyxml2::XMLPrinter file_stream) const
virtual

Reimplemented from Layer.

Definition at line 1352 of file recurrent_layer.cpp.

Member Data Documentation

◆ activation_function

ActivationFunction activation_function = ActivationFunction::HyperbolicTangent
protected

Activation function variable.

Definition at line 243 of file recurrent_layer.h.

◆ biases

Tensor<type, 1> biases
protected

Bias is a neuron parameter that is summed with the neuron's weighted inputs and passed through the neuron's trabsfer function to generate the neuron's output.

Definition at line 233 of file recurrent_layer.h.

◆ display

bool display = true
protected

Display messages to screen.

Definition at line 249 of file recurrent_layer.h.

◆ hidden_states

Tensor<type, 1> hidden_states
protected

Definition at line 245 of file recurrent_layer.h.

◆ input_weights

Tensor<type, 2> input_weights
protected

Definition at line 235 of file recurrent_layer.h.

◆ recurrent_weights

Tensor<type, 2> recurrent_weights
protected

This matrix containing conection strengths from a recurrent layer inputs to its neurons.

Definition at line 239 of file recurrent_layer.h.

◆ timesteps

Index timesteps = 1
protected

Definition at line 228 of file recurrent_layer.h.


The documentation for this class was generated from the following files: