Sequential< InputDataType, OutputDataType, Residual, CustomLayers > Class Template Reference

Implementation of the Sequential class. More...

Public Member Functions

 Sequential (const bool model=true)
 Create the Sequential object using the specified parameters. 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 > &&, 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...

 
void DeleteModules ()
 
arma::mat const & Delta () const
 Get the delta. More...

 
arma::mat & Delta ()
 Modify the delta. More...

 
template
<
typename
eT
>
void Forward (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 (arma::Mat< eT > &&input, 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...

 
std::vector< LayerTypes< CustomLayers... > > & Model ()
 Return the model modules. 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 &, const unsigned int)
 Serialize the layer. More...

 

Detailed Description


template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat, bool Residual = false, typename... CustomLayers>
class mlpack::ann::Sequential< InputDataType, OutputDataType, Residual, CustomLayers >

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.

@article{He15,
author = {Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun},
title = {Deep Residual Learning for Image Recognition},
year = {2015},
url = {https://arxiv.org/abs/1512.03385},
eprint = {1512.03385},
}

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.

Template Parameters
InputDataTypeType of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).
OutputDataTypeType of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).
ResidualIf true, use the object as a Residual block.

Definition at line 106 of file layer_types.hpp.

Constructor & Destructor Documentation

◆ Sequential()

Sequential ( const bool  model = true)

Create the Sequential object using the specified parameters.

Parameters
modelExpose the all network modules.

◆ ~Sequential()

~Sequential ( )

Destroy the Sequential object.

Member Function Documentation

◆ Add() [1/2]

void Add ( Args...  args)
inline

Definition at line 126 of file sequential.hpp.

◆ Add() [2/2]

void Add ( LayerTypes< CustomLayers... >  layer)
inline

◆ Backward()

void Backward ( const arma::Mat< eT > &&  ,
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.

Parameters
inputThe propagated input activation.
gyThe backpropagated error.
gThe calculated gradient.

◆ DeleteModules()

◆ Delta() [1/2]

arma::mat const& Delta ( ) const
inline

Get the delta.

Definition at line 167 of file sequential.hpp.

◆ Delta() [2/2]

arma::mat& Delta ( )
inline

Modify the delta.

Definition at line 169 of file sequential.hpp.

◆ Forward()

void Forward ( 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.

Parameters
inputInput data used for evaluating the specified function.
outputResulting output activation.

◆ Gradient() [1/3]

void Gradient ( arma::Mat< eT > &&  input,
arma::Mat< eT > &&  error,
arma::Mat< eT > &&   
)

◆ Gradient() [2/3]

arma::mat const& Gradient ( ) const
inline

Get the gradient.

Definition at line 172 of file sequential.hpp.

◆ Gradient() [3/3]

arma::mat& Gradient ( )
inline

Modify the gradient.

Definition at line 174 of file sequential.hpp.

References Sequential< InputDataType, OutputDataType, Residual, CustomLayers >::serialize().

◆ InputParameter() [1/2]

arma::mat const& InputParameter ( ) const
inline

Get the input parameter.

Definition at line 157 of file sequential.hpp.

◆ InputParameter() [2/2]

arma::mat& InputParameter ( )
inline

Modify the input parameter.

Definition at line 159 of file sequential.hpp.

◆ Model()

std::vector<LayerTypes<CustomLayers...> >& Model ( )
inline

Return the model modules.

Definition at line 141 of file sequential.hpp.

◆ OutputParameter() [1/2]

arma::mat const& OutputParameter ( ) const
inline

Get the output parameter.

Definition at line 162 of file sequential.hpp.

◆ OutputParameter() [2/2]

arma::mat& OutputParameter ( )
inline

Modify the output parameter.

Definition at line 164 of file sequential.hpp.

◆ Parameters() [1/2]

const arma::mat& Parameters ( ) const
inline

Return the initial point for the optimization.

Definition at line 152 of file sequential.hpp.

◆ Parameters() [2/2]

arma::mat& Parameters ( )
inline

Modify the initial point for the optimization.

Definition at line 154 of file sequential.hpp.

◆ serialize()

void serialize ( Archive &  ,
const unsigned  int 
)

The documentation for this class was generated from the following files:
  • /home/jenkins-mlpack/mlpack.org/_src/mlpack-3.2.1/src/mlpack/methods/ann/layer/layer_types.hpp
  • /home/jenkins-mlpack/mlpack.org/_src/mlpack-3.2.1/src/mlpack/methods/ann/layer/sequential.hpp