HardTanH< InputDataType, OutputDataType > Class Template Reference

The Hard Tanh activation function, defined by. More...

Public Member Functions

 HardTanH (const double maxValue=1, const double minValue=-1)
 Create the HardTanH object using the specified parameters. 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...

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

 
double const & MaxValue () const
 Get the maximum value. More...

 
double & MaxValue ()
 Modify the maximum value. More...

 
double const & MinValue () const
 Get the minimum value. More...

 
double & MinValue ()
 Modify the minimum value. 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 uint32_t)
 Serialize the layer. More...

 

Detailed Description


template
<
typename
InputDataType
=
arma::mat
,
typename
OutputDataType
=
arma::mat
>

class mlpack::ann::HardTanH< InputDataType, OutputDataType >

The Hard Tanh activation function, defined by.

\begin{eqnarray*} f(x) &=& \left\{ \begin{array}{lr} max & : x > maxValue \\ min & : x \le minValue \\ x & : otherwise \end{array} \right. \\ f'(x) &=& \left\{ \begin{array}{lr} 0 & : x > maxValue \\ 0 & : x \le minValue \\ 1 & : otherwise \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 49 of file hard_tanh.hpp.

Constructor & Destructor Documentation

◆ HardTanH()

HardTanH ( const double  maxValue = 1,
const double  minValue = -1 
)

Create the HardTanH object using the specified parameters.

The range of the linear region can be adjusted by specifying the maxValue and minValue. Default (maxValue = 1, minValue = -1).

Parameters
maxValueRange of the linear region maximum value.
minValueRange of the linear region minimum value.

Member Function Documentation

◆ Backward()

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.

Using the results from the feed forward pass.

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

◆ Delta() [1/2]

OutputDataType const& Delta ( ) const
inline

Get the delta.

Definition at line 92 of file hard_tanh.hpp.

◆ Delta() [2/2]

OutputDataType& Delta ( )
inline

Modify the delta.

Definition at line 94 of file hard_tanh.hpp.

◆ Forward()

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.

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

◆ MaxValue() [1/2]

double const& MaxValue ( ) const
inline

Get the maximum value.

Definition at line 97 of file hard_tanh.hpp.

◆ MaxValue() [2/2]

double& MaxValue ( )
inline

Modify the maximum value.

Definition at line 99 of file hard_tanh.hpp.

◆ MinValue() [1/2]

double const& MinValue ( ) const
inline

Get the minimum value.

Definition at line 102 of file hard_tanh.hpp.

◆ MinValue() [2/2]

double& MinValue ( )
inline

Modify the minimum value.

Definition at line 104 of file hard_tanh.hpp.

References HardTanH< InputDataType, OutputDataType >::serialize().

◆ OutputParameter() [1/2]

OutputDataType const& OutputParameter ( ) const
inline

Get the output parameter.

Definition at line 87 of file hard_tanh.hpp.

◆ OutputParameter() [2/2]

OutputDataType& OutputParameter ( )
inline

Modify the output parameter.

Definition at line 89 of file hard_tanh.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the layer.

Referenced by HardTanH< InputDataType, OutputDataType >::MinValue().


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/ann/layer/hard_tanh.hpp