ConcatType< MatType > Class Template Reference

Implementation of the Concat class. More...

Inheritance diagram for ConcatType< MatType >:

Public Member Functions

 ConcatType ()
 Create the Concat object. More...

 
 ConcatType (const size_t axis)
 Create the Concat object, specifying a particular axis on which the layer outputs should be concatenated. More...

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

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

 
virtual ~ConcatType ()
 Destroy the layers held by the model. More...

 
size_t Axis () const
 Get the axis of concatenation. More...

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

 
void Backward (const MatType &, const MatType &gy, MatType &g, const size_t index)
 This is the overload of Backward() that runs only a specific layer with the given input. More...

 
ConcatTypeClone () const
 Clone the ConcatType object. This handles polymorphism correctly. More...

 
void ComputeOutputDimensions ()
 Compute the output dimensions of the MultiLayer 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 &, const MatType &error, MatType &)
 Calculate the gradient using the output delta and the input activation. More...

 
void Gradient (const MatType &input, const MatType &error, MatType &gradient, const size_t index)
 This is the overload of Gradient() that runs a specific layer with the given input. More...

 
ConcatTypeoperator= (const ConcatType &other)
 Copy the given ConcatType layer. More...

 
ConcatTypeoperator= (ConcatType &&other)
 Take ownership of the given ConcatType layer. More...

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

 
- Public Member Functions inherited from MultiLayer< MatType >
 MultiLayer ()
 Create an empty MultiLayer that holds no layers of its own. More...

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

 
 MultiLayer (MultiLayer &&other)
 Take ownership of the layers of the given MultiLayer. More...

 
virtual ~MultiLayer ()
 Virtual destructor: delete all held layers. More...

 
template<typename LayerType , typename... Args>
void Add (Args... args)
 
void Add (Layer< MatType > *layer)
 
void Forward (const MatType &input, MatType &output, const size_t start, const size_t end)
 Perform a forward pass with the given input data, but only on a subset of the layers in the MultiLayer. More...

 
virtual double Loss () const
 Compute the loss that should be added to the objective. More...

 
const std::vector< Layer< MatType > * > Network () const
 Get the network (series of layers) held by this MultiLayer. More...

 
std::vector< Layer< MatType > * > & Network ()
 Modify the network (series of layers) held by this MultiLayer. More...

 
MultiLayeroperator= (const MultiLayer &other)
 Copy the given MultiLayer. More...

 
MultiLayeroperator= (MultiLayer &&other)
 Take ownership of the given MultiLayer. More...

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

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

 
virtual size_t WeightSize () const
 Return the number of weights in the MultiLayer. 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...

 
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 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 Member Functions inherited from MultiLayer< MatType >
void InitializeBackwardPassMemory (const size_t batchSize)
 Initialize memory that will be used by each layer for the backwards pass, assuming that the input will have the given batchSize. More...

 
void InitializeForwardPassMemory (const size_t batchSize)
 Initialize memory that will be used by each layer for the forward pass, assuming that the input will have the given batchSize. More...

 
void InitializeGradientPassMemory (MatType &gradient)
 Initialize memory for the gradient pass. More...

 
- Protected Attributes inherited from MultiLayer< MatType >
size_t inSize
 
MatType layerDeltaMatrix
 This matrix stores all of the backwards pass results of each layer when Backward() is called. More...

 
std::vector< MatType > layerDeltas
 These are aliases of layerDeltaMatrix for each layer. More...

 
std::vector< MatType > layerGradients
 Gradient aliases for each layer. More...

 
MatType layerOutputMatrix
 This matrix stores all of the outputs of each layer when Forward() is called. More...

 
std::vector< MatType > layerOutputs
 These are aliases of layerOutputMatrix for each layer. More...

 
std::vector< Layer< MatType > * > network
 The internally-held network. More...

 
size_t totalInputSize
 
size_t totalOutputSize
 
- 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::ConcatType< MatType >

Implementation of the Concat class.

The Concat class works as a feed-forward fully connected network container which plugs various layers together.

NOTE: this class is not intended to exist for long! It will be replaced with a more flexible DAG network type.

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

Definition at line 35 of file concat.hpp.

Constructor & Destructor Documentation

◆ ConcatType() [1/4]

Create the Concat object.

The axis used for concatenation will be the last one.

Referenced by ConcatType< MatType >::Clone().

◆ ConcatType() [2/4]

ConcatType ( const size_t  axis)

Create the Concat object, specifying a particular axis on which the layer outputs should be concatenated.

Parameters
axisConcat axis.

◆ ~ConcatType()

virtual ~ConcatType ( )
virtual

Destroy the layers held by the model.

◆ ConcatType() [3/4]

ConcatType ( const ConcatType< MatType > &  other)

Copy the given ConcatType layer.

◆ ConcatType() [4/4]

ConcatType ( ConcatType< MatType > &&  other)

Take ownership of the given ConcatType layer.

Member Function Documentation

◆ Axis()

size_t Axis ( ) const
inline

Get the axis of concatenation.

Definition at line 131 of file concat.hpp.

◆ Backward() [1/2]

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

Ordinary feed backward pass of a neural network, using 3rd-order tensors as input, calculating the function f(x) by propagating x backwards through f.

Using the results from the feed forward pass.

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

Reimplemented from MultiLayer< MatType >.

Referenced by ConcatType< MatType >::Clone().

◆ Backward() [2/2]

void Backward ( const MatType &  ,
const MatType &  gy,
MatType &  g,
const size_t  index 
)

This is the overload of Backward() that runs only a specific layer with the given input.

Parameters
*(input) The propagated input activation.
gyThe backpropagated error.
gThe calculated gradient.
indexThe index of the layer to run.

◆ Clone()

ConcatType* Clone ( ) const
inlinevirtual

◆ ComputeOutputDimensions()

void ComputeOutputDimensions ( )
inlinevirtual

Compute the output dimensions of the MultiLayer using InputDimensions().

This computes the dimensions of each layer held by the MultiLayer, and the output dimensions are set to the output dimensions of the last layer.

Reimplemented from MultiLayer< MatType >.

Definition at line 136 of file concat.hpp.

References Layer< MatType >::inputDimensions, MultiLayer< MatType >::network, Layer< MatType >::OutputDimensions(), Layer< MatType >::outputDimensions, ConcatType< MatType >::serialize(), MultiLayer< MatType >::totalInputSize, and MultiLayer< MatType >::totalOutputSize.

◆ 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 MultiLayer< MatType >.

Referenced by ConcatType< MatType >::Clone().

◆ Gradient() [1/2]

void Gradient ( const MatType &  ,
const MatType &  error,
MatType &   
)
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 MultiLayer< MatType >.

Referenced by ConcatType< MatType >::Clone().

◆ Gradient() [2/2]

void Gradient ( const MatType &  input,
const MatType &  error,
MatType &  gradient,
const size_t  index 
)

This is the overload of Gradient() that runs a specific layer with the given input.

Parameters
inputThe input parameter used for calculating the gradient.
errorThe calculated error.
gradientThe calculated gradient.
Theindex of the layer to run.

◆ operator=() [1/2]

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

Copy the given ConcatType layer.

Referenced by ConcatType< MatType >::Clone().

◆ operator=() [2/2]

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

Take ownership of the given ConcatType layer.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the layer.

Referenced by ConcatType< MatType >::ComputeOutputDimensions().


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