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

The PReLU activation function, defined by (where alpha is trainable) More...

#include <parametric_relu.hpp>

Public Member Functions

 PReLU (const double userAlpha=0.03)
 Create the PReLU object using the specified parameters. More...
 
void Reset ()
 
template<typename InputType , typename OutputType >
void Forward (const InputType &input, OutputType &output)
 Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f. More...
 
template<typename DataType >
void Backward (const DataType &input, const DataType &gy, DataType &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...
 
OutputDataType const & Parameters () const
 Get the parameters.
 
OutputDataType & Parameters ()
 Modify the parameters.
 
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.
 
double const & Alpha () const
 Get the non zero gradient.
 
double & Alpha ()
 Modify the non zero gradient.
 
size_t WeightSize () const
 Get size of 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::PReLU< InputDataType, OutputDataType >

The PReLU activation function, defined by (where alpha is trainable)

\begin{eqnarray*} f(x) &=& \max(x, alpha*x) \\ f'(x) &=& \left\{ \begin{array}{lr} 1 & : x > 0 \\ alpha & : x \le 0 \end{array} \right. \end{eqnarray*}

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

◆ PReLU()

template<typename InputDataType , typename OutputDataType >
mlpack::ann::PReLU< InputDataType, OutputDataType >::PReLU ( const double  userAlpha = 0.03)

Create the PReLU object using the specified parameters.

The non zero gradient can be adjusted by specifying tha parameter alpha in the range 0 to 1. Default (alpha = 0.03). This parameter is trainable.

Parameters
userAlphaNon zero gradient

Member Function Documentation

◆ Backward()

template<typename InputDataType , typename OutputDataType >
template<typename DataType >
void mlpack::ann::PReLU< InputDataType, OutputDataType >::Backward ( const DataType &  input,
const DataType &  gy,
DataType &  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
inputThe propagated input activation.
gyThe backpropagated error.
gThe calculated gradient.

◆ Forward()

template<typename InputDataType , typename OutputDataType >
template<typename InputType , typename OutputType >
void mlpack::ann::PReLU< InputDataType, OutputDataType >::Forward ( const InputType &  input,
OutputType &  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 >
template<typename eT >
void mlpack::ann::PReLU< InputDataType, OutputDataType >::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.

◆ Reset()

template<typename InputDataType , typename OutputDataType >
void mlpack::ann::PReLU< InputDataType, OutputDataType >::Reset ( )

Set value of alpha to the one given by user.


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