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

Implementation of the Highway layer. More...

#include <highway.hpp>

Public Member Functions

 Highway ()
 Create the Highway object.
 
 Highway (const size_t inSize, const bool model=true)
 Create the Highway object. More...
 
 ~Highway ()
 Destroy the Highway object.
 
void Reset ()
 Reset the layer parameter.
 
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 Backward (const arma::Mat< eT > &, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
 Ordinary feed-backward pass of a neural network, calculating the function f(x) by propagating x backwards through f. More...
 
template<typename eT >
void Gradient (const arma::Mat< eT > &input, const arma::Mat< eT > &error, arma::Mat< eT > &gradient)
 Calculate the gradient using the output delta and the input activation. More...
 
template<class LayerType , class... Args>
void Add (Args... args)
 Add a new module to the model. More...
 
void Add (LayerTypes< CustomLayers... > layer)
 Add a new module to the model. More...
 
std::vector< LayerTypes< CustomLayers... > > & Model ()
 Return the modules of the model.
 
OutputDataType const & Parameters () const
 Get the parameters.
 
OutputDataType & Parameters ()
 Modify the parameters.
 
InputDataType const & InputParameter () const
 Get the input parameter.
 
InputDataType & InputParameter ()
 Modify the input parameter.
 
OutputDataType const & OutputParameter () const
 Get the output parameter.
 
OutputDataType & OutputParameter ()
 Modify the output parameter.
 
OutputDataType const & Delta () const
 Get the delta.
 
OutputDataType & Delta ()
 Modify the delta.
 
OutputDataType const & Gradient () const
 Get the gradient.
 
OutputDataType & Gradient ()
 Modify the gradient.
 
size_t InSize () const
 Get the number of input units.
 
size_t InputShape () const
 Get the shape of the input.
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t)
 Serialize the layer.
 

Detailed Description

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat, typename... CustomLayers>
class mlpack::ann::Highway< InputDataType, OutputDataType, CustomLayers >

Implementation of the Highway layer.

The Highway class can vary its behavior between that of feed-forward fully connected network container and that of a layer which simply passes its inputs through depending on the transform gate. Note that the size of the input and output matrices of this class should be equal.

For more information, refer the following paper.

@article{Srivastava2015,
author = {Rupesh Kumar Srivastava, Klaus Greff, Jurgen Schmidhuber},
title = {Training Very Deep Networks},
journal = {Advances in Neural Information Processing Systems},
year = {2015},
url = {https://arxiv.org/abs/1507.06228},
}
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

◆ Highway()

template<typename InputDataType , typename OutputDataType , typename... CustomLayers>
mlpack::ann::Highway< InputDataType, OutputDataType, CustomLayers >::Highway ( const size_t  inSize,
const bool  model = true 
)

Create the Highway object.

Parameters
inSizeThe number of input units.
modelExpose all the network modules.

Member Function Documentation

◆ Add() [1/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat, typename... CustomLayers>
template<class LayerType , class... Args>
void mlpack::ann::Highway< InputDataType, OutputDataType, CustomLayers >::Add ( Args...  args)
inline

Add a new module to the model.

Parameters
argsThe layer parameter.

◆ Add() [2/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat, typename... CustomLayers>
void mlpack::ann::Highway< InputDataType, OutputDataType, CustomLayers >::Add ( LayerTypes< CustomLayers... >  layer)
inline

Add a new module to the model.

Parameters
layerThe Layer to be added to the model.

◆ Backward()

template<typename InputDataType , typename OutputDataType , typename... CustomLayers>
template<typename eT >
void mlpack::ann::Highway< InputDataType, OutputDataType, CustomLayers >::Backward ( const arma::Mat< eT > &  ,
const arma::Mat< eT > &  gy,
arma::Mat< eT > &  g 
)

Ordinary feed-backward pass of a neural network, calculating the function f(x) by propagating x backwards through f.

Using the results from the feed-forward pass.

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

◆ Forward()

template<typename InputDataType , typename OutputDataType , typename... CustomLayers>
template<typename eT >
void mlpack::ann::Highway< InputDataType, OutputDataType, CustomLayers >::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.

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

◆ Gradient()

template<typename InputDataType , typename OutputDataType , typename... CustomLayers>
template<typename eT >
void mlpack::ann::Highway< InputDataType, OutputDataType, CustomLayers >::Gradient ( const arma::Mat< eT > &  input,
const arma::Mat< eT > &  error,
arma::Mat< eT > &  gradient 
)

Calculate the gradient using the output delta and the input activation.

Parameters
inputThe input parameter used for calculating the gradient.
errorThe calculated error.
gradientThe calculated gradient.

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