MultiplyMergeType< InputType, OutputType > Class Template Reference

Implementation of the MultiplyMerge module class. More...

Inheritance diagram for MultiplyMergeType< InputType, OutputType >:

Public Member Functions

 MultiplyMergeType (const bool model=false, const bool run=true)
 Create the MultiplyMerge object using the specified parameters. More...

 
 ~MultiplyMergeType ()
 Destructor to release allocated memory. More...

 
void Backward (const InputType &, const OutputType &gy, OutputType &g)
 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. More...

 
MultiplyMergeTypeClone () const
 Clone the MultiplyMergeType object. This handles polymorphism correctly. More...

 
void Forward (const InputType &, OutputType &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 InputType &input, const OutputType &error, OutputType &gradient)
 
 MultiplyMerge (const MultiplyMerge &layer)
 Copy Constructor. More...

 
 MultiplyMerge (MultiplyMerge &&layer)
 Move Constructor. More...

 
MultiplyMergeoperator= (const MultiplyMerge &layer)
 Copy assignment operator. More...

 
MultiplyMergeoperator= (MultiplyMerge &&layer)
 Move assignment operator. More...

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

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

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

 
size_t WeightSize () const
 Get the size of the weights. More...

 
- Public Member Functions inherited from MultiLayer< InputType, OutputType >
 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...

 
void Add (Args... args)
 
void Add (Layer< InputType > *layer)
 
virtual void Backward (const InputType &input, const InputType &gy, InputType &g)
 Perform a backward pass with the given data. More...

 
virtual void ComputeOutputDimensions ()
 Compute the output dimensions of the MultiLayer using InputDimensions(). More...

 
virtual void Forward (const InputType &input, InputType &output)
 Perform a forward pass with the given input data. More...

 
void Forward (const InputType &input, InputType &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 void Gradient (const InputType &input, const InputType &error, InputType &gradient)
 Compute the gradients of each layer. More...

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

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

 
std::vector< Layer< InputType > *> & 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...

 
void serialize (Archive &ar, const uint32_t)
 Serialize the MultiLayer. More...

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

 
- Public Member Functions inherited from Layer< InputType >
 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 InputType &, const InputType &)
 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...

 
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< InputType, OutputType >
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 (InputType &gradient)
 Initialize memory for the gradient pass. More...

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

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

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

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

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

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

 
size_t totalInputSize
 
size_t totalOutputSize
 
- Protected Attributes inherited from Layer< InputType >
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
InputType
=
arma::mat
,
typename
OutputType
=
arma::mat
>

class mlpack::ann::MultiplyMergeType< InputType, OutputType >

Implementation of the MultiplyMerge module class.

The MultiplyMerge class multiplies the output of various modules element-wise.

Template Parameters
InputTypeType of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).
OutputTypeType of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).

Definition at line 40 of file multiply_merge.hpp.

Constructor & Destructor Documentation

◆ MultiplyMergeType()

MultiplyMergeType ( const bool  model = false,
const bool  run = true 
)

Create the MultiplyMerge object using the specified parameters.

Parameters
modelExpose all the network modules.
runCall the Forward/Backward method before the output is merged.

Referenced by MultiplyMergeType< InputType, OutputType >::Clone().

◆ ~MultiplyMergeType()

Destructor to release allocated memory.

Member Function Documentation

◆ Backward()

void Backward ( const InputType &  ,
const OutputType &  gy,
OutputType &  g 
)

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.

Referenced by MultiplyMergeType< InputType, OutputType >::Clone().

◆ Clone()

◆ Forward()

void Forward ( const InputType &  ,
OutputType &  output 
)

Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f.

Parameters
*(input) Input data used for evaluating the specified function.
outputResulting output activation.

Referenced by MultiplyMergeType< InputType, OutputType >::Clone().

◆ Gradient()

void Gradient ( const InputType &  input,
const OutputType &  error,
OutputType &  gradient 
)

◆ MultiplyMerge() [1/2]

MultiplyMerge ( const MultiplyMerge layer)

Copy Constructor.

◆ MultiplyMerge() [2/2]

Move Constructor.

◆ operator=() [1/2]

MultiplyMerge& operator= ( const MultiplyMerge layer)

Copy assignment operator.

◆ operator=() [2/2]

MultiplyMerge& operator= ( MultiplyMerge &&  layer)

Move assignment operator.

◆ Parameters() [1/2]

OutputType const& Parameters ( ) const
inlinevirtual

Get the parameters.

Reimplemented from Layer< InputType >.

Definition at line 103 of file multiply_merge.hpp.

◆ Parameters() [2/2]

OutputType& Parameters ( )
inlinevirtual

Modify the parameters.

Reimplemented from Layer< InputType >.

Definition at line 105 of file multiply_merge.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the layer.

Referenced by MultiplyMergeType< InputType, OutputType >::WeightSize().

◆ WeightSize()

size_t WeightSize ( ) const
inlinevirtual

Get the size of the weights.

Reimplemented from MultiLayer< InputType, OutputType >.

Definition at line 108 of file multiply_merge.hpp.

References MultiplyMergeType< InputType, OutputType >::serialize().


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