mlpack
Public Member Functions | List of all members
mlpack::ann::Constant< InputDataType, OutputDataType > Class Template Reference

Implementation of the constant layer. More...

#include <constant.hpp>

Public Member Functions

 Constant (const size_t outSize=0, const double scalar=0.0)
 Create the Constant object that outputs a given constant scalar value given any input value. More...
 
template<typename InputType , typename OutputType >
void Forward (const InputType &input, OutputType &output)
 Ordinary feed forward pass of a neural network. More...
 
template<typename DataType >
void Backward (const DataType &, const DataType &, DataType &g)
 Ordinary feed backward pass of a neural network. More...
 
OutputDataType & OutputParameter () const
 Get the output parameter.
 
OutputDataType & OutputParameter ()
 Modify the output parameter.
 
OutputDataType & Delta () const
 Get the delta.
 
OutputDataType & Delta ()
 Modify the delta.
 
size_t OutSize () const
 Get the output size.
 
size_t WeightSize () const
 Get the size of the weights.
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t)
 Serialize the layer.
 

Detailed Description

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
class mlpack::ann::Constant< InputDataType, OutputDataType >

Implementation of the constant layer.

The constant layer outputs a given constant value given any input value.

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).

Constructor & Destructor Documentation

◆ Constant()

template<typename InputDataType , typename OutputDataType >
mlpack::ann::Constant< InputDataType, OutputDataType >::Constant ( const size_t  outSize = 0,
const double  scalar = 0.0 
)

Create the Constant object that outputs a given constant scalar value given any input value.

Parameters
outSizeThe number of output units.
scalarThe constant value used to create the constant output.

Member Function Documentation

◆ Backward()

template<typename InputDataType , typename OutputDataType >
template<typename DataType >
void mlpack::ann::Constant< InputDataType, OutputDataType >::Backward ( const DataType &  ,
const DataType &  ,
DataType &  g 
)

Ordinary feed backward pass of a neural network.

The backward pass of the constant layer is returns always a zero output error matrix.

Parameters
*(input) The propagated input activation.
*(gy) The backpropagated error.
gThe calculated gradient.

◆ Forward()

template<typename InputDataType , typename OutputDataType >
template<typename InputType , typename OutputType >
void mlpack::ann::Constant< InputDataType, OutputDataType >::Forward ( const InputType &  input,
OutputType &  output 
)

Ordinary feed forward pass of a neural network.

The forward pass fills the output with the specified constant parameter.

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

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