SoftmaxType< MatType > Class Template Reference

Implementation of the Softmax layer. More...

Inheritance diagram for SoftmaxType< MatType >:

Public Member Functions

 SoftmaxType ()
 Create the Softmax object. More...

 
 SoftmaxType (const SoftmaxType &other)
 Copy the given SoftmaxType. More...

 
 SoftmaxType (SoftmaxType &&other)
 Take ownership of the given SoftmaxType. More...

 
virtual ~SoftmaxType ()
 Virtual destructor. More...

 
void Backward (const MatType &input, const MatType &gy, MatType &g)
 Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards through f. More...

 
SoftmaxTypeClone () const
 Clone the SoftmaxType object. This handles polymorphism correctly. More...

 
void Forward (const MatType &input, MatType &output)
 Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f. More...

 
SoftmaxTypeoperator= (const SoftmaxType &other)
 Copy the given SoftmaxType. More...

 
SoftmaxTypeoperator= (SoftmaxType &&other)
 Take ownership of the given SoftmaxType. 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 CustomInitialize (MatType &, const size_t)
 Override the weight matrix of the layer. 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
<
typename
MatType
=
arma::mat
>

class mlpack::ann::SoftmaxType< MatType >

Implementation of the Softmax layer.

The softmax function takes as input a vector of K real numbers, and normalizes it into a probability distribution consisting of K probabilities proportional to the exponentials of the input numbers. It should be used for inference only and not with NLL loss (use LogSoftMax instead).

Template Parameters
MatTypeMatrix representation to accept as input and use for computation.

Definition at line 35 of file softmax.hpp.

Constructor & Destructor Documentation

◆ SoftmaxType() [1/3]

◆ ~SoftmaxType()

virtual ~SoftmaxType ( )
inlinevirtual

Virtual destructor.

Definition at line 45 of file softmax.hpp.

◆ SoftmaxType() [2/3]

SoftmaxType ( const SoftmaxType< MatType > &  other)

Copy the given SoftmaxType.

◆ SoftmaxType() [3/3]

SoftmaxType ( SoftmaxType< MatType > &&  other)

Take ownership of the given SoftmaxType.

Member Function Documentation

◆ Backward()

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

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.

Reimplemented from Layer< MatType >.

Referenced by CategoricalDQN< OutputLayerType, InitType, NetworkType >::Backward(), and SoftmaxType< arma::mat >::~SoftmaxType().

◆ Clone()

SoftmaxType* Clone ( ) const
inlinevirtual

Clone the SoftmaxType object. This handles polymorphism correctly.

Implements Layer< MatType >.

Definition at line 42 of file softmax.hpp.

◆ Forward()

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

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.

Reimplemented from Layer< MatType >.

Referenced by CategoricalDQN< OutputLayerType, InitType, NetworkType >::Forward(), CategoricalDQN< OutputLayerType, InitType, NetworkType >::Predict(), and SoftmaxType< arma::mat >::~SoftmaxType().

◆ operator=() [1/2]

SoftmaxType& operator= ( const SoftmaxType< MatType > &  other)

Copy the given SoftmaxType.

Referenced by SoftmaxType< arma::mat >::~SoftmaxType().

◆ operator=() [2/2]

SoftmaxType& operator= ( SoftmaxType< MatType > &&  other)

Take ownership of the given SoftmaxType.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the layer.

Referenced by SoftmaxType< arma::mat >::~SoftmaxType().


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