BilinearInterpolationType< InputType, OutputType > Class Template Reference

Definition and Implementation of the Bilinear Interpolation Layer. More...

Inheritance diagram for BilinearInterpolationType< InputType, OutputType >:

Public Member Functions

 BilinearInterpolationType ()
 Create the BilinearInterpolationType object. More...

 
 BilinearInterpolationType (const size_t outRowSize, const size_t outColSize)
 The constructor for the Bilinear Interpolation. More...

 
void Backward (const InputType &, const OutputType &gradient, OutputType &output)
 Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards through f. More...

 
void Forward (const InputType &input, OutputType &output)
 Forward pass through the layer. More...

 
size_t const & OutColSize () const
 Get the column size of the output. More...

 
size_t & OutColSize ()
 Modify the column size of the output. More...

 
const std::vector< size_t > & OutputDimensions () const
 
size_t const & OutRowSize () const
 Get the row size of the output. More...

 
size_t & OutRowSize ()
 Modify the row size of the output. More...

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

 
- Public Member Functions inherited from Layer< InputType, OutputType >
 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 Backward (const InputType &, const InputType &, InputType &)
 Performs a backpropagation step through the layer, with respect to the given input. More...

 
virtual LayerClone () const=0
 Make a copy of the object. More...

 
virtual void ComputeOutputDimensions ()
 Compute the output dimensions. More...

 
virtual void CustomInitialize (InputType &, const size_t)
 Override the weight matrix of the layer. More...

 
virtual void Forward (const InputType &, InputType &)
 Takes an input object, and computes the corresponding output of the layer. More...

 
virtual void Forward (const InputType &, const InputType &)
 Takes an input and output object, and computes the corresponding loss of the layer. More...

 
virtual void Gradient (const InputType &, const InputType &, InputType &)
 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 InputType & Parameters () const
 Get the parameters. More...

 
virtual InputType & Parameters ()
 Set the parameters. More...

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

 
virtual void SetWeights (typename InputType ::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< InputType, OutputType >
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::BilinearInterpolationType< InputType, OutputType >

Definition and Implementation of the Bilinear Interpolation Layer.

Bilinear Interpolation is an mathematical technique, primarily used for scaling purposes. It is an extension of linear interpolation, for interpolating functions of two variables on a rectangular grid. The key idea is to perform linear interpolation first in one direction (e.g., along x-axis), and then again in the other direction (i.e., y-axis), on four different known points in the grid. This way, we represent any arbitrary point, present within the grid, as a function of those four points.

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

Constructor & Destructor Documentation

◆ BilinearInterpolationType() [1/2]

◆ BilinearInterpolationType() [2/2]

BilinearInterpolationType ( const size_t  outRowSize,
const size_t  outColSize 
)

The constructor for the Bilinear Interpolation.

The input size will be set by the given input when the layer is used.

Parameters
outRowSizeNumber of output rows.
outColSizeNumber of output columns.

Member Function Documentation

◆ Backward()

void Backward ( const InputType &  ,
const OutputType &  gradient,
OutputType &  output 
)

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. Since the layer does not have any learn-able parameters, we just have to down-sample the gradient to make its size compatible with the input size.

Parameters
*(input) The input matrix.
gradientThe computed backward gradient.
outputThe resulting down-sampled output.

◆ Forward()

void Forward ( const InputType &  input,
OutputType &  output 
)

Forward pass through the layer.

The layer interpolates the matrix using the given Bilinear Interpolation method.

Parameters
inputThe input matrix.
outputThe resulting interpolated output matrix.

◆ OutColSize() [1/2]

size_t const& OutColSize ( ) const
inline

Get the column size of the output.

Definition at line 99 of file bilinear_interpolation.hpp.

◆ OutColSize() [2/2]

size_t& OutColSize ( )
inline

Modify the column size of the output.

Definition at line 101 of file bilinear_interpolation.hpp.

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

◆ OutputDimensions()

const std::vector<size_t>& OutputDimensions ( ) const
inline

◆ OutRowSize() [1/2]

size_t const& OutRowSize ( ) const
inline

Get the row size of the output.

Definition at line 94 of file bilinear_interpolation.hpp.

◆ OutRowSize() [2/2]

size_t& OutRowSize ( )
inline

Modify the row size of the output.

Definition at line 96 of file bilinear_interpolation.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

The documentation for this class was generated from the following file: