Implementation of the Sequential class. More...
Public Member Functions | |
| Sequential (const bool model=true) | |
| Create the Sequential object using the specified parameters. More... | |
| Sequential (const bool model, const bool ownsLayers) | |
| Create the Sequential object using the specified parameters. More... | |
| Sequential (const Sequential &layer) | |
| Copy constructor. More... | |
| ~Sequential () | |
| Destroy the Sequential object. More... | |
| template<class LayerType , class... Args> | |
| void | Add (Args... args) |
| void | Add (LayerTypes< CustomLayers... > layer) |
template < typename eT > | |
| void | Backward (const arma::Mat< eT > &, const arma::Mat< eT > &gy, arma::Mat< eT > &g) |
| Ordinary feed backward pass of a neural network, using 3rd-order tensors as input, calculating the function f(x) by propagating x backwards through f. More... | |
| arma::mat const & | Delta () const |
| Get the delta. More... | |
| arma::mat & | Delta () |
| Modify the delta. More... | |
template < typename eT > | |
| void | Forward (const arma::Mat< eT > &input, arma::Mat< eT > &output) |
| Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f. More... | |
template < typename eT > | |
| void | Gradient (const arma::Mat< eT > &input, const arma::Mat< eT > &error, arma::Mat< eT > &) |
| arma::mat const & | Gradient () const |
| Get the gradient. More... | |
| arma::mat & | Gradient () |
| Modify the gradient. More... | |
| arma::mat const & | InputParameter () const |
| Get the input parameter. More... | |
| arma::mat & | InputParameter () |
| Modify the input parameter. More... | |
| size_t | InputShape () const |
| std::vector< LayerTypes< CustomLayers... > > & | Model () |
| Return the model modules. More... | |
| Sequential & | operator= (const Sequential &layer) |
| Copy assignment operator. More... | |
| arma::mat const & | OutputParameter () const |
| Get the output parameter. More... | |
| arma::mat & | OutputParameter () |
| Modify the output parameter. More... | |
| const arma::mat & | Parameters () const |
| Return the initial point for the optimization. More... | |
| arma::mat & | Parameters () |
| Modify the initial point for the optimization. More... | |
template < typename Archive > | |
| void | serialize (Archive &ar, const uint32_t) |
| Serialize the layer. More... | |
Implementation of the Sequential class.
The sequential class works as a feed-forward fully connected network container which plugs various layers together.
This class can also be used as a container for a residual block. In that case, the sizes of the input and output matrices of this class should be equal. A typedef has been added for use as a Residual<> class.
For more information, refer the following paper.
Note: If this class is used as the first layer of a network, it should be preceded by IdentityLayer<>.
Note: This class should at least have two layers for a call to its Gradient() function.
| InputDataType | Type of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
| OutputDataType | Type of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
| Residual | If true, use the object as a Residual block. |
Definition at line 147 of file layer_types.hpp.
| Sequential | ( | const bool | model = true | ) |
Create the Sequential object using the specified parameters.
| model | Expose the all network modules. |
| Sequential | ( | const bool | model, |
| const bool | ownsLayers | ||
| ) |
Create the Sequential object using the specified parameters.
| model | Expose all the network modules. |
| ownsLayers | If true, then this module will delete its layers when deallocated. |
| Sequential | ( | const Sequential< InputDataType, OutputDataType, Residual, CustomLayers > & | layer | ) |
Copy constructor.
| ~Sequential | ( | ) |
Destroy the Sequential object.
|
inline |
Definition at line 141 of file sequential.hpp.
Referenced by DuelingDQN< OutputLayerType, InitType, CompleteNetworkType, FeatureNetworkType, AdvantageNetworkType, ValueNetworkType >::DuelingDQN().
|
inline |
Definition at line 148 of file sequential.hpp.
| void Backward | ( | const arma::Mat< eT > & | , |
| const arma::Mat< eT > & | gy, | ||
| arma::Mat< eT > & | g | ||
| ) |
Ordinary feed backward pass of a neural network, using 3rd-order tensors as input, calculating the function f(x) by propagating x backwards through f.
Using the results from the feed forward pass.
| * | (input) The propagated input activation. |
| gy | The backpropagated error. |
| g | The calculated gradient. |
|
inline |
Get the delta.
Definition at line 177 of file sequential.hpp.
|
inline |
Modify the delta.
Definition at line 179 of file sequential.hpp.
| void Forward | ( | const arma::Mat< eT > & | input, |
| arma::Mat< eT > & | output | ||
| ) |
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f.
| input | Input data used for evaluating the specified function. |
| output | Resulting output activation. |
| void Gradient | ( | const arma::Mat< eT > & | input, |
| const arma::Mat< eT > & | error, | ||
| arma::Mat< eT > & | |||
| ) |
|
inline |
Get the gradient.
Definition at line 182 of file sequential.hpp.
|
inline |
Modify the gradient.
Definition at line 184 of file sequential.hpp.
References Sequential< InputDataType, OutputDataType, Residual, CustomLayers >::InputShape(), and Sequential< InputDataType, OutputDataType, Residual, CustomLayers >::serialize().
|
inline |
Get the input parameter.
Definition at line 167 of file sequential.hpp.
|
inline |
Modify the input parameter.
Definition at line 169 of file sequential.hpp.
| size_t InputShape | ( | ) | const |
|
inline |
Return the model modules.
Definition at line 151 of file sequential.hpp.
| Sequential& operator= | ( | const Sequential< InputDataType, OutputDataType, Residual, CustomLayers > & | layer | ) |
Copy assignment operator.
|
inline |
Get the output parameter.
Definition at line 172 of file sequential.hpp.
|
inline |
Modify the output parameter.
Definition at line 174 of file sequential.hpp.
|
inline |
Return the initial point for the optimization.
Definition at line 162 of file sequential.hpp.
|
inline |
Modify the initial point for the optimization.
Definition at line 164 of file sequential.hpp.
| void serialize | ( | Archive & | ar, |
| const uint32_t | |||
| ) |
Serialize the layer.
Referenced by Sequential< InputDataType, OutputDataType, Residual, CustomLayers >::Gradient().