mlpack  master
Public Member Functions | Private Member Functions | Private Attributes | List of all members
mlpack::ann::LeakyReLU< InputDataType, OutputDataType > Class Template Reference

The LeakyReLU activation function, defined by. More...

Public Member Functions

 LeakyReLU (const double alpha=0.03)
 Create the LeakyReLU object using the specified parameters. More...
 
double const & Alpha () const
 Get the non zero gradient. More...
 
double & Alpha ()
 Modify the non zero gradient. More...
 
template<typename DataType >
void Backward (const DataType &&input, DataType &&gy, DataType &&g)
 Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards through f. More...
 
OutputDataType const & Delta () const
 Get the delta. More...
 
OutputDataType & Delta ()
 Modify the delta. More...
 
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...
 
InputDataType const & InputParameter () const
 Get the input parameter. More...
 
InputDataType & InputParameter ()
 Modify the input parameter. More...
 
OutputDataType const & OutputParameter () const
 Get the output parameter. More...
 
OutputDataType & OutputParameter ()
 Modify the output parameter. More...
 
template<typename Archive >
void Serialize (Archive &ar, const unsigned int)
 Serialize the layer. More...
 

Private Member Functions

double Deriv (const double x)
 Computes the first derivative of the LeakyReLU function. More...
 
template<typename InputType , typename OutputType >
void Deriv (const InputType &x, OutputType &y)
 Computes the first derivative of the LeakyReLU function. More...
 
double Fn (const double x)
 Computes the LeakReLU function. More...
 
template<typename eT >
void Fn (const arma::Mat< eT > &x, arma::Mat< eT > &y)
 Computes the Leaky ReLU function using a dense matrix as input. More...
 

Private Attributes

double alpha
 Leakyness Parameter in the range 0 <alpha< 1. More...
 
OutputDataType delta
 Locally-stored delta object. More...
 
InputDataType inputParameter
 Locally-stored input parameter object. More...
 
OutputDataType outputParameter
 Locally-stored output parameter object. More...
 

Detailed Description

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

The LeakyReLU activation function, defined by.

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

Definition at line 44 of file leaky_relu.hpp.

Constructor & Destructor Documentation

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::LeakyReLU ( const double  alpha = 0.03)

Create the LeakyReLU 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)

Parameters
alphaNon zero gradient

Member Function Documentation

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double const& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Alpha ( ) const
inline

Get the non zero gradient.

Definition at line 94 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::alpha.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Alpha ( )
inline
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename DataType >
void mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Backward ( const DataType &&  input,
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.
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType const& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Delta ( ) const
inline

Get the delta.

Definition at line 89 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::delta.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Delta ( )
inline

Modify the delta.

Definition at line 91 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::delta.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Deriv ( const double  x)
inlineprivate

Computes the first derivative of the LeakyReLU function.

Parameters
xInput data.
Returns
f'(x)

Definition at line 134 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::alpha.

Referenced by mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Deriv().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename InputType , typename OutputType >
void mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Deriv ( const InputType &  x,
OutputType &  y 
)
inlineprivate

Computes the first derivative of the LeakyReLU function.

Parameters
yInput activations.
xThe resulting derivatives.

Definition at line 147 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Deriv().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Fn ( const double  x)
inlineprivate

Computes the LeakReLU function.

Parameters
xInput data.
Returns
f(x).

Definition at line 111 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::alpha.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename eT >
void mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Fn ( const arma::Mat< eT > &  x,
arma::Mat< eT > &  y 
)
inlineprivate

Computes the Leaky ReLU function using a dense matrix as input.

Parameters
xInput data.
yThe resulting output activation.

Definition at line 123 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::alpha.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename InputType , typename OutputType >
void mlpack::ann::LeakyReLU< 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.
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType const& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::InputParameter ( ) const
inline

Get the input parameter.

Definition at line 79 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::inputParameter.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::InputParameter ( )
inline

Modify the input parameter.

Definition at line 81 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::inputParameter.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType const& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::OutputParameter ( ) const
inline

Get the output parameter.

Definition at line 84 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::outputParameter.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType& mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::OutputParameter ( )
inline

Modify the output parameter.

Definition at line 86 of file leaky_relu.hpp.

References mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::outputParameter.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename Archive >
void mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Serialize ( Archive &  ar,
const unsigned  int 
)

Member Data Documentation

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::alpha
private
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::delta
private

Locally-stored delta object.

Definition at line 158 of file leaky_relu.hpp.

Referenced by mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::Delta().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::inputParameter
private

Locally-stored input parameter object.

Definition at line 161 of file leaky_relu.hpp.

Referenced by mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::InputParameter().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::outputParameter
private

Locally-stored output parameter object.

Definition at line 164 of file leaky_relu.hpp.

Referenced by mlpack::ann::LeakyReLU< InputDataType, OutputDataType >::OutputParameter().


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