TransposedConvolutionType< ForwardConvolutionRule, BackwardConvolutionRule, GradientConvolutionRule, InputType, OutputType > Class Template Reference

Implementation of the Transposed Convolution class. More...

Inheritance diagram for TransposedConvolutionType< ForwardConvolutionRule, BackwardConvolutionRule, GradientConvolutionRule, InputType, OutputType >:

Public Member Functions

 TransposedConvolutionType ()
 Create the Transposed Convolution object. More...

 
 TransposedConvolutionType (const size_t inSize, const size_t outSize, const size_t kernelWidth, const size_t kernelHeight, const size_t strideWidth=1, const size_t strideHeight=1, const size_t padW=0, const size_t padH=0, const size_t inputWidth=0, const size_t inputHeight=0, const size_t outputWidth=0, const size_t outputHeight=0, const std::string &paddingType="None")
 Create the Transposed Convolution object using the specified number of input maps, output maps, filter size, stride and padding parameter. More...

 
 TransposedConvolutionType (const size_t inSize, const size_t outSize, const size_t kernelWidth, const size_t kernelHeight, const size_t strideWidth, const size_t strideHeight, const std::tuple< size_t, size_t > &padW, const std::tuple< size_t, size_t > &padH, const size_t inputWidth=0, const size_t inputHeight=0, const size_t outputWidth=0, const size_t outputHeight=0, const std::string &paddingType="None")
 Create the Transposed Convolution object using the specified number of input maps, output maps, filter size, stride and padding parameter. 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 through f. More...

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

 
OutputType & Bias ()
 Modify the bias of the layer. More...

 
void Forward (const InputType &input, 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 &, const OutputType &error, OutputType &gradient)
 Calculate the gradient using the output delta and the input activation. More...

 
size_t const & InputHeight () const
 Get the input height. More...

 
size_t & InputHeight ()
 Modify the input height. More...

 
size_t const & InputSize () const
 Get the input size. More...

 
size_t const & InputWidth () const
 Get the input width. More...

 
size_t & InputWidth ()
 Modify input the width. More...

 
size_t const & KernelHeight () const
 Get the kernel height. More...

 
size_t & KernelHeight ()
 Modify the kernel height. More...

 
size_t const & KernelWidth () const
 Get the kernel width. More...

 
size_t & KernelWidth ()
 Modify the kernel width. More...

 
const std::vector< size_t > & OutputDimensions () const
 
size_t const & OutputHeight () const
 Get the output height. More...

 
size_t & OutputHeight ()
 Modify the output height. More...

 
size_t const & OutputSize () const
 Get the output size. More...

 
size_t const & OutputWidth () const
 Get the output width. More...

 
size_t & OutputWidth ()
 Modify the output width. More...

 
size_t const & PadHBottom () const
 Get the bottom padding height. More...

 
size_t & PadHBottom ()
 Modify the bottom padding height. More...

 
size_t const & PadHTop () const
 Get the top padding height. More...

 
size_t & PadHTop ()
 Modify the top padding height. More...

 
size_t const & PadWLeft () const
 Get the left padding width. More...

 
size_t & PadWLeft ()
 Modify the left padding width. More...

 
size_t const & PadWRight () const
 Get the right padding width. More...

 
size_t & PadWRight ()
 Modify the right padding width. 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...

 
void SetWeights (const typename OutputType::elem_type *weightsPtr)
 
size_t const & StrideHeight () const
 Get the stride height. More...

 
size_t & StrideHeight ()
 Modify the stride height. More...

 
size_t const & StrideWidth () const
 Get the stride width. More...

 
size_t & StrideWidth ()
 Modify the stride width. More...

 
arma::Cube< typename OutputType::elem_type > const & Weight () const
 Get the weight of the layer. More...

 
arma::Cube< typename OutputType::elem_type > & Weight ()
 Modify the weight of the layer. More...

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

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

 

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 ForwardConvolutionRule = NaiveConvolution<ValidConvolution>, typename BackwardConvolutionRule = NaiveConvolution<ValidConvolution>, typename GradientConvolutionRule = NaiveConvolution<ValidConvolution>, typename InputType = arma::mat, typename OutputType = arma::mat>
class mlpack::ann::TransposedConvolutionType< ForwardConvolutionRule, BackwardConvolutionRule, GradientConvolutionRule, InputType, OutputType >

Implementation of the Transposed Convolution class.

The Transposed Convolution class represents a single layer of a neural network.

Template Parameters
ForwardConvolutionRuleConvolution to perform forward process.
BackwardConvolutionRuleConvolution to perform backward process.
GradientConvolutionRuleConvolution to calculate gradient.
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 50 of file transposed_convolution.hpp.

Constructor & Destructor Documentation

◆ TransposedConvolutionType() [1/3]

Create the Transposed Convolution object.

◆ TransposedConvolutionType() [2/3]

TransposedConvolutionType ( const size_t  inSize,
const size_t  outSize,
const size_t  kernelWidth,
const size_t  kernelHeight,
const size_t  strideWidth = 1,
const size_t  strideHeight = 1,
const size_t  padW = 0,
const size_t  padH = 0,
const size_t  inputWidth = 0,
const size_t  inputHeight = 0,
const size_t  outputWidth = 0,
const size_t  outputHeight = 0,
const std::string &  paddingType = "None" 
)

Create the Transposed Convolution object using the specified number of input maps, output maps, filter size, stride and padding parameter.

Note: The equivalent stride of a transposed convolution operation is always equal to 1. In this implementation, stride of filter represents the stride of the associated convolution operation. Note: Padding of input represents padding of associated convolution operation.

Parameters
inSizeThe number of input maps.
outSizeThe number of output maps.
kernelWidthWidth of the filter/kernel.
kernelHeightHeight of the filter/kernel.
strideWidthStride of filter application in the x direction.
strideHeightStride of filter application in the y direction.
padWPadding width of the input.
padHPadding height of the input.
inputWidthThe width of the input data.
inputHeightThe height of the input data.
outputWidthThe width of the output data.
outputHeightThe height of the output data.
paddingTypeThe type of padding (Valid or Same). Defaults to None.

◆ TransposedConvolutionType() [3/3]

TransposedConvolutionType ( const size_t  inSize,
const size_t  outSize,
const size_t  kernelWidth,
const size_t  kernelHeight,
const size_t  strideWidth,
const size_t  strideHeight,
const std::tuple< size_t, size_t > &  padW,
const std::tuple< size_t, size_t > &  padH,
const size_t  inputWidth = 0,
const size_t  inputHeight = 0,
const size_t  outputWidth = 0,
const size_t  outputHeight = 0,
const std::string &  paddingType = "None" 
)

Create the Transposed Convolution object using the specified number of input maps, output maps, filter size, stride and padding parameter.

Note: The equivalent stride of a transposed convolution operation is always equal to 1. In this implementation, stride of filter represents the stride of the associated convolution operation. Note: Padding of input represents padding of associated convolution operation.

Parameters
inSizeThe number of input maps.
outSizeThe number of output maps.
kernelWidthWidth of the filter/kernel.
kernelHeightHeight of the filter/kernel.
strideWidthStride of filter application in the x direction.
strideHeightStride of filter application in the y direction.
padWA two-value tuple indicating padding widths of the input. First value is padding at left side. Second value is padding on right side.
padHA two-value tuple indicating padding heights of the input. First value is padding at top. Second value is padding on bottom.
inputWidthThe width of the input data.
inputHeightThe height of the input data.
outputWidthThe width of the output data.
outputHeightThe height of the output data.
paddingTypeThe type of padding (Valid or Same). Defaults to None.

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

Using the results from the feed forward pass.

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

◆ Bias() [1/2]

OutputType const& Bias ( ) const
inline

Get the bias of the layer.

Definition at line 189 of file transposed_convolution.hpp.

◆ Bias() [2/2]

OutputType& Bias ( )
inline

Modify the bias of the layer.

Definition at line 191 of file transposed_convolution.hpp.

◆ Forward()

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

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.

◆ Gradient()

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

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

Parameters
*(input) The input parameter used for calculating the gradient.
errorThe calculated error.
gradientThe calculated gradient.

◆ InputHeight() [1/2]

size_t const& InputHeight ( ) const
inline

Get the input height.

Definition at line 199 of file transposed_convolution.hpp.

◆ InputHeight() [2/2]

size_t& InputHeight ( )
inline

Modify the input height.

Definition at line 201 of file transposed_convolution.hpp.

◆ InputSize()

size_t const& InputSize ( ) const
inline

Get the input size.

Definition at line 214 of file transposed_convolution.hpp.

◆ InputWidth() [1/2]

size_t const& InputWidth ( ) const
inline

Get the input width.

Definition at line 194 of file transposed_convolution.hpp.

◆ InputWidth() [2/2]

size_t& InputWidth ( )
inline

Modify input the width.

Definition at line 196 of file transposed_convolution.hpp.

◆ KernelHeight() [1/2]

size_t const& KernelHeight ( ) const
inline

Get the kernel height.

Definition at line 225 of file transposed_convolution.hpp.

◆ KernelHeight() [2/2]

size_t& KernelHeight ( )
inline

Modify the kernel height.

Definition at line 227 of file transposed_convolution.hpp.

◆ KernelWidth() [1/2]

size_t const& KernelWidth ( ) const
inline

Get the kernel width.

Definition at line 220 of file transposed_convolution.hpp.

◆ KernelWidth() [2/2]

size_t& KernelWidth ( )
inline

Modify the kernel width.

Definition at line 222 of file transposed_convolution.hpp.

◆ OutputDimensions()

◆ OutputHeight() [1/2]

size_t const& OutputHeight ( ) const
inline

Get the output height.

Definition at line 209 of file transposed_convolution.hpp.

◆ OutputHeight() [2/2]

size_t& OutputHeight ( )
inline

Modify the output height.

Definition at line 211 of file transposed_convolution.hpp.

◆ OutputSize()

size_t const& OutputSize ( ) const
inline

Get the output size.

Definition at line 217 of file transposed_convolution.hpp.

◆ OutputWidth() [1/2]

size_t const& OutputWidth ( ) const
inline

Get the output width.

Definition at line 204 of file transposed_convolution.hpp.

◆ OutputWidth() [2/2]

size_t& OutputWidth ( )
inline

Modify the output width.

Definition at line 206 of file transposed_convolution.hpp.

◆ PadHBottom() [1/2]

size_t const& PadHBottom ( ) const
inline

Get the bottom padding height.

Definition at line 245 of file transposed_convolution.hpp.

◆ PadHBottom() [2/2]

size_t& PadHBottom ( )
inline

Modify the bottom padding height.

Definition at line 247 of file transposed_convolution.hpp.

◆ PadHTop() [1/2]

size_t const& PadHTop ( ) const
inline

Get the top padding height.

Definition at line 240 of file transposed_convolution.hpp.

◆ PadHTop() [2/2]

size_t& PadHTop ( )
inline

Modify the top padding height.

Definition at line 242 of file transposed_convolution.hpp.

◆ PadWLeft() [1/2]

size_t const& PadWLeft ( ) const
inline

Get the left padding width.

Definition at line 250 of file transposed_convolution.hpp.

◆ PadWLeft() [2/2]

size_t& PadWLeft ( )
inline

Modify the left padding width.

Definition at line 252 of file transposed_convolution.hpp.

◆ PadWRight() [1/2]

size_t const& PadWRight ( ) const
inline

Get the right padding width.

Definition at line 255 of file transposed_convolution.hpp.

◆ PadWRight() [2/2]

size_t& PadWRight ( )
inline

Modify the right padding width.

Definition at line 257 of file transposed_convolution.hpp.

◆ Parameters() [1/2]

OutputType const& Parameters ( ) const
inlinevirtual

Get the parameters.

Reimplemented from Layer< InputType, OutputType >.

Definition at line 176 of file transposed_convolution.hpp.

◆ Parameters() [2/2]

OutputType& Parameters ( )
inlinevirtual

Modify the parameters.

Reimplemented from Layer< InputType, OutputType >.

Definition at line 178 of file transposed_convolution.hpp.

◆ serialize()

◆ SetWeights()

void SetWeights ( const typename OutputType::elem_type *  weightsPtr)

◆ StrideHeight() [1/2]

size_t const& StrideHeight ( ) const
inline

Get the stride height.

Definition at line 235 of file transposed_convolution.hpp.

◆ StrideHeight() [2/2]

size_t& StrideHeight ( )
inline

Modify the stride height.

Definition at line 237 of file transposed_convolution.hpp.

◆ StrideWidth() [1/2]

size_t const& StrideWidth ( ) const
inline

Get the stride width.

Definition at line 230 of file transposed_convolution.hpp.

◆ StrideWidth() [2/2]

size_t& StrideWidth ( )
inline

Modify the stride width.

Definition at line 232 of file transposed_convolution.hpp.

◆ Weight() [1/2]

arma::Cube<typename OutputType::elem_type> const& Weight ( ) const
inline

Get the weight of the layer.

Definition at line 181 of file transposed_convolution.hpp.

◆ Weight() [2/2]

arma::Cube<typename OutputType::elem_type>& Weight ( )
inline

Modify the weight of the layer.

Definition at line 186 of file transposed_convolution.hpp.

◆ WeightSize()

size_t WeightSize ( ) const
inlinevirtual

Get the size of the weight matrix.

Reimplemented from Layer< InputType, OutputType >.

Definition at line 260 of file transposed_convolution.hpp.


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