AddType< MatType > Class Template Reference

Implementation of the Add layer. More...

Inheritance diagram for AddType< MatType >:

Public Member Functions

 AddType ()
 Create the AddType object. More...

 
 AddType (const AddType &other)
 Copy the given AddType layer. More...

 
 AddType (AddType &&other)
 Take ownership of the given AddType layer. More...

 
virtual ~AddType ()
 
void Backward (const MatType &, const MatType &gy, MatType &g)
 Backward pass: send weights backwards (the bias does not affect anything). More...

 
AddTypeClone () const
 Clone the AddType object. This handles polymorphism correctly. More...

 
void ComputeOutputDimensions ()
 Compute the output dimensions of the layer, based on the internal values of InputDimensions(). More...

 
void Forward (const MatType &input, MatType &output)
 Forward pass: add the bias to the input. More...

 
void Gradient (const MatType &, const MatType &error, MatType &gradient)
 Calculate the gradient using the output and the input activation. More...

 
AddTypeoperator= (const AddType &other)
 Copy the given AddType layer. More...

 
AddTypeoperator= (AddType &&other)
 Take ownership of the given AddType layer. More...

 
const MatType & Parameters () const
 Return the weights of the network. More...

 
MatType & Parameters ()
 Modify the weights of the network. More...

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

 
void SetWeights (typename MatType::elem_type *weightPtr)
 Set the weights of the layer to use the given memory. More...

 
size_t WeightSize () const
 Get the size of weights. 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 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...

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

 
template
<
typename
Archive
>
void serialize (Archive &ar, const uint32_t)
 Serialize the layer. 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...

 

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
>

class mlpack::ann::AddType< MatType >

Implementation of the Add layer.

The Add module applies a bias term to the incoming data.

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

Definition at line 29 of file add.hpp.

Constructor & Destructor Documentation

◆ AddType() [1/3]

AddType ( )

Create the AddType object.

The output size of the layer will be the same as the input size.

Referenced by AddType< MatType >::Clone(), and AddType< MatType >::~AddType().

◆ ~AddType()

◆ AddType() [2/3]

AddType ( const AddType< MatType > &  other)

Copy the given AddType layer.

◆ AddType() [3/3]

AddType ( AddType< MatType > &&  other)

Take ownership of the given AddType layer.

Member Function Documentation

◆ Backward()

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

Backward pass: send weights backwards (the bias does not affect anything).

Parameters
*(input) The propagated input activation.
gyThe backpropagated error.
gThe calculated gradient.

Reimplemented from Layer< MatType >.

Referenced by AddType< MatType >::~AddType().

◆ Clone()

AddType* Clone ( ) const
inlinevirtual

Clone the AddType object. This handles polymorphism correctly.

Implements Layer< MatType >.

Definition at line 39 of file add.hpp.

References AddType< MatType >::AddType().

◆ ComputeOutputDimensions()

void ComputeOutputDimensions ( )
virtual

Compute the output dimensions of the layer, based on the internal values of InputDimensions().

Reimplemented from Layer< MatType >.

Referenced by AddType< MatType >::WeightSize().

◆ Forward()

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

Forward pass: add the bias to the input.

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

Reimplemented from Layer< MatType >.

Referenced by AddType< MatType >::~AddType().

◆ Gradient()

void Gradient ( const MatType &  ,
const MatType &  error,
MatType &  gradient 
)
virtual

Calculate the gradient using the output and the input activation.

Parameters
*(input) The propagated input.
errorThe calculated error.
gradientThe calculated gradient.

Reimplemented from Layer< MatType >.

Referenced by AddType< MatType >::~AddType().

◆ operator=() [1/2]

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

Copy the given AddType layer.

Referenced by AddType< MatType >::~AddType().

◆ operator=() [2/2]

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

Take ownership of the given AddType layer.

◆ Parameters() [1/2]

const MatType& Parameters ( ) const
inlinevirtual

Return the weights of the network.

Reimplemented from Layer< MatType >.

Definition at line 84 of file add.hpp.

◆ Parameters() [2/2]

MatType& Parameters ( )
inlinevirtual

Modify the weights of the network.

Reimplemented from Layer< MatType >.

Definition at line 86 of file add.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the layer.

Referenced by AddType< MatType >::WeightSize().

◆ SetWeights()

void SetWeights ( typename MatType::elem_type *  weightPtr)
virtual

Set the weights of the layer to use the given memory.

Reimplemented from Layer< MatType >.

Referenced by AddType< MatType >::WeightSize().

◆ WeightSize()

size_t WeightSize ( ) const
inlinevirtual

Get the size of weights.

Reimplemented from Layer< MatType >.

Definition at line 89 of file add.hpp.

References AddType< MatType >::ComputeOutputDimensions(), AddType< MatType >::serialize(), and AddType< MatType >::SetWeights().


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