BaseLayer< ActivationFunction, MatType > Class Template Reference

Implementation of the base layer. More...

Inheritance diagram for BaseLayer< ActivationFunction, MatType >:

Public Member Functions

 BaseLayer ()
 Create the BaseLayer object. More...

 
virtual ~BaseLayer ()
 
void Backward (const MatType &input, const MatType &gy, MatType &g)
 Backward pass: compute the function f(x) by propagating x backwards through f, using the results from the forward pass. More...

 
BaseLayerClone () const
 Clone the BaseLayer object. This handles polymorphism correctly. More...

 
void Forward (const MatType &input, MatType &output)
 Forward pass: apply the activation to the inputs. More...

 
template
<
typename
Archive
>
void serialize (Archive &ar, const uint32_t)
 Serialize the layer. More...

 
- Public Member Functions inherited from Layer< MatType >
 Layer ()
 Default constructor. More...

 
 Layer (const Layer &layer)
 Copy constructor. This is not responsible for copying weights! More...

 
 Layer (Layer &&layer)
 Move constructor. This is not responsible for moving weights! More...

 
virtual ~Layer ()
 Default deconstructor. More...

 
virtual void ComputeOutputDimensions ()
 Compute the output dimensions. More...

 
virtual void Forward (const MatType &, const MatType &)
 Takes an input and output object, and computes the corresponding loss of the layer. More...

 
virtual void Gradient (const MatType &, const MatType &, MatType &)
 Computing the gradient of the layer with respect to its own input. More...

 
const std::vector< size_t > & InputDimensions () const
 Get the input dimensions. More...

 
std::vector< size_t > & InputDimensions ()
 Modify the input dimensions. More...

 
virtual double Loss ()
 Get the layer loss. More...

 
virtual Layeroperator= (const Layer &layer)
 Copy assignment operator. This is not responsible for copying weights! More...

 
virtual Layeroperator= (Layer &&layer)
 Move assignment operator. This is not responsible for moving weights! More...

 
const std::vector< size_t > & OutputDimensions ()
 Get the output dimensions. More...

 
virtual size_t OutputSize () final
 Get the number of elements in the output from this layer. More...

 
virtual const MatType & Parameters () const
 Get the parameters. More...

 
virtual MatType & Parameters ()
 Set the parameters. More...

 
template
<
typename
Archive
>
void serialize (Archive &ar, const uint32_t)
 Serialize the layer. More...

 
virtual void SetWeights (typename MatType::elem_type *)
 Reset the layer parameter. More...

 
virtual bool const & Training () const
 Get whether the layer is currently in training mode. More...

 
virtual bool & Training ()
 Modify whether the layer is currently in training mode. More...

 
virtual size_t WeightSize () const
 Get the total number of trainable weights in the layer. More...

 

Additional Inherited Members

- Protected Attributes inherited from Layer< MatType >
std::vector< size_t > inputDimensions
 Logical input dimensions of each point. More...

 
std::vector< size_t > outputDimensions
 Logical output dimensions of each point. More...

 
bool training
 If true, the layer is in training mode; otherwise, it is in testing mode. More...

 
bool validOutputDimensions
 This is true if ComputeOutputDimensions() has been called, and outputDimensions can be considered to be up-to-date. More...

 

Detailed Description


template
<
class
ActivationFunction
=
LogisticFunction
,
typename
MatType
=
arma::mat
>

class mlpack::ann::BaseLayer< ActivationFunction, MatType >

Implementation of the base layer.

The base layer works as a metaclass which attaches various functions to the embedding layer.

A few convenience typedefs are given:

  • Sigmoid
  • ReLU
  • TanH
  • Softplus
  • HardSigmoid
  • Swish
  • Mish
  • LiSHT
  • GELU
  • ELiSH
  • Elliot
  • Gaussian
  • HardSwish
  • TanhExp
  • SILU
Template Parameters
ActivationFunctionActivation function used for the embedding layer.

Definition at line 66 of file base_layer.hpp.

Constructor & Destructor Documentation

◆ BaseLayer()

BaseLayer ( )
inline

Create the BaseLayer object.

Definition at line 72 of file base_layer.hpp.

Referenced by BaseLayer< ActivationFunction, MatType >::Clone().

◆ ~BaseLayer()

virtual ~BaseLayer ( )
inlinevirtual

Definition at line 78 of file base_layer.hpp.

Member Function Documentation

◆ Backward()

void Backward ( const MatType &  input,
const MatType &  gy,
MatType &  g 
)
inlinevirtual

Backward pass: compute the function f(x) by propagating x backwards through f, using the results from the forward pass.

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

Reimplemented from Layer< MatType >.

Definition at line 105 of file base_layer.hpp.

◆ Clone()

BaseLayer* Clone ( ) const
inlinevirtual

Clone the BaseLayer object. This handles polymorphism correctly.

Implements Layer< MatType >.

Definition at line 84 of file base_layer.hpp.

References BaseLayer< ActivationFunction, MatType >::BaseLayer().

◆ Forward()

void Forward ( const MatType &  input,
MatType &  output 
)
inlinevirtual

Forward pass: apply the activation to the inputs.

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

Reimplemented from Layer< MatType >.

Definition at line 92 of file base_layer.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)
inline

Serialize the layer.

Definition at line 116 of file base_layer.hpp.


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