Linear3DType< MatType, RegularizerType > Class Template Reference

Implementation of the Linear3D layer class. More...

Inheritance diagram for Linear3DType< MatType, RegularizerType >:

Public Member Functions

 Linear3DType ()
 Create the Linear3D object. More...

 
 Linear3DType (const size_t outSize, RegularizerType regularizer=RegularizerType())
 Create the Linear3D layer object using the specified number of output units. More...

 
 Linear3DType (const Linear3DType &other)
 Copy the given Linear3DType (but not weights). More...

 
 Linear3DType (Linear3DType &&other)
 Take ownership of the given Linear3DType (but not weights). More...

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

 
MatType const & Bias () const
 Get the bias of the layer. More...

 
MatType & Bias ()
 Modify the bias weights of the layer. More...

 
Linear3DTypeClone () const
 Clone the Linear3DType object. This handles polymorphism correctly. More...

 
void ComputeOutputDimensions ()
 Compute the output dimensions for the layer, using InputDimensions(). 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...

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

 
Linear3DTypeoperator= (const Linear3DType &other)
 Copy the given Linear3DType (but not weights). More...

 
Linear3DTypeoperator= (Linear3DType &&other)
 Take ownership of the given Linear3DType (but not weights). More...

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

 
MatType & Parameters ()
 Modify the parameters. More...

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

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

 
MatType const & Weight () const
 Get the weight of the layer. More...

 
MatType & Weight ()
 Modify the weight of the layer. More...

 
size_t WeightSize () const
 Return the number of weight elements. 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 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
=
arma::mat
,
typename
RegularizerType
=
NoRegularizer
>

class mlpack::ann::Linear3DType< MatType, RegularizerType >

Implementation of the Linear3D layer class.

The Linear class represents a single layer of a neural network.

Shape of input : (inSize * nPoints, batchSize) Shape of output : (outSize * nPoints, batchSize)

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

Definition at line 38 of file linear3d.hpp.

Constructor & Destructor Documentation

◆ Linear3DType() [1/4]

◆ Linear3DType() [2/4]

Linear3DType ( const size_t  outSize,
RegularizerType  regularizer = RegularizerType() 
)

Create the Linear3D layer object using the specified number of output units.

Parameters
outSizeThe number of output units.
regularizerThe regularizer to use, optional.

◆ ~Linear3DType()

◆ Linear3DType() [3/4]

Linear3DType ( const Linear3DType< MatType, RegularizerType > &  other)

Copy the given Linear3DType (but not weights).

◆ Linear3DType() [4/4]

Linear3DType ( Linear3DType< MatType, RegularizerType > &&  other)

Take ownership of the given Linear3DType (but not weights).

Member Function Documentation

◆ Backward()

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

Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards trough f.

Using the results from the feed forward pass.

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

Reimplemented from Layer< MatType >.

Referenced by Linear3DType< MatType, RegularizerType >::~Linear3DType().

◆ Bias() [1/2]

MatType const& Bias ( ) const
inline

Get the bias of the layer.

Definition at line 118 of file linear3d.hpp.

◆ Bias() [2/2]

MatType& Bias ( )
inline

Modify the bias weights of the layer.

Definition at line 120 of file linear3d.hpp.

◆ Clone()

Linear3DType* Clone ( ) const
inlinevirtual

Clone the Linear3DType object. This handles polymorphism correctly.

Implements Layer< MatType >.

Definition at line 55 of file linear3d.hpp.

References Linear3DType< MatType, RegularizerType >::Linear3DType().

◆ ComputeOutputDimensions()

void ComputeOutputDimensions ( )
virtual

Compute the output dimensions for the layer, using InputDimensions().

Reimplemented from Layer< MatType >.

Referenced by Linear3DType< MatType, RegularizerType >::WeightSize().

◆ 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 Linear3DType< MatType, RegularizerType >::~Linear3DType().

◆ Gradient()

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

Calculate the gradient using the output delta and the input activation.

Parameters
inputThe input parameter used for calculating the gradient.
errorThe calculated error.
gradientThe calculated gradient.

Reimplemented from Layer< MatType >.

Referenced by Linear3DType< MatType, RegularizerType >::~Linear3DType().

◆ operator=() [1/2]

Linear3DType& operator= ( const Linear3DType< MatType, RegularizerType > &  other)

Copy the given Linear3DType (but not weights).

Referenced by Linear3DType< MatType, RegularizerType >::~Linear3DType().

◆ operator=() [2/2]

Linear3DType& operator= ( Linear3DType< MatType, RegularizerType > &&  other)

Take ownership of the given Linear3DType (but not weights).

◆ Parameters() [1/2]

MatType const& Parameters ( ) const
inlinevirtual

Get the parameters.

Reimplemented from Layer< MatType >.

Definition at line 108 of file linear3d.hpp.

◆ Parameters() [2/2]

MatType& Parameters ( )
inlinevirtual

Modify the parameters.

Reimplemented from Layer< MatType >.

Definition at line 110 of file linear3d.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the layer.

Referenced by Linear3DType< MatType, RegularizerType >::WeightSize().

◆ SetWeights()

void SetWeights ( typename MatType::elem_type *  )
virtual

Reset the layer parameter.

The method is called to assigned the allocated memory to the internal layer parameters like weights and biases. The method should be called before the first call of Forward(input, output). If you do not respect this rule, Forward(input, output) and Backward(input, gy, g) might compute incorrect results.

Parameters
weightsPtrThis pointer should be used as the first element of the memory that is allocated for this layer. In general, SetWeights() implementations should use MakeAlias() with weightsPtr to wrap the weights of a layer.

Reimplemented from Layer< MatType >.

Referenced by Linear3DType< MatType, RegularizerType >::~Linear3DType().

◆ Weight() [1/2]

MatType const& Weight ( ) const
inline

Get the weight of the layer.

Definition at line 113 of file linear3d.hpp.

◆ Weight() [2/2]

MatType& Weight ( )
inline

Modify the weight of the layer.

Definition at line 115 of file linear3d.hpp.

◆ WeightSize()

size_t WeightSize ( ) const
inlinevirtual

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