MaxPoolingComponent : Maxpooling component was firstly used in ConvNet for selecting an representative activation in an area. More...
#include <nnet-component.h>
Public Member Functions | |
void | Init (int32 input_dim, int32 output_dim, int32 pool_size, int32 pool_stride) |
MaxpoolingComponent (int32 input_dim, int32 output_dim, int32 pool_size, int32 pool_stride) | |
MaxpoolingComponent () | |
virtual std::string | Type () const |
virtual void | InitFromString (std::string args) |
Initialize, typically from a line of a config file. More... | |
virtual int32 | InputDim () const |
Get size of input vectors. More... | |
virtual int32 | OutputDim () const |
Get size of output vectors. More... | |
virtual void | Propagate (const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out) const |
Perform forward pass propagation Input->Output. More... | |
virtual void | Backprop (const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &, const CuMatrixBase< BaseFloat > &out_deriv, Component *to_update, CuMatrix< BaseFloat > *in_deriv) const |
Perform backward pass propagation of the derivative, and also either update the model (if to_update == this) or update another model or compute the model derivative (otherwise). More... | |
virtual bool | BackpropNeedsInput () const |
virtual bool | BackpropNeedsOutput () const |
virtual Component * | Copy () const |
Copy component (deep copy). More... | |
virtual void | Read (std::istream &is, bool binary) |
virtual void | Write (std::ostream &os, bool binary) const |
Write component to stream. More... | |
virtual std::string | Info () const |
Public Member Functions inherited from Component | |
Component () | |
virtual int32 | Index () const |
Returns the index in the sequence of layers in the neural net; intended only to be used in debugging information. More... | |
virtual void | SetIndex (int32 index) |
virtual std::vector< int32 > | Context () const |
Return a vector describing the temporal context this component requires for each frame of output, as a sorted list. More... | |
void | Propagate (const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in, CuMatrix< BaseFloat > *out) const |
A non-virtual propagate function that first resizes output if necessary. More... | |
virtual | ~Component () |
Protected Attributes | |
int32 | input_dim_ |
int32 | output_dim_ |
int32 | pool_size_ |
int32 | pool_stride_ |
Additional Inherited Members | |
Static Public Member Functions inherited from Component | |
static Component * | ReadNew (std::istream &is, bool binary) |
Read component from stream. More... | |
static Component * | NewFromString (const std::string &initializer_line) |
Initialize the Component from one line that will contain first the type, e.g. More... | |
static Component * | NewComponentOfType (const std::string &type) |
Return a new Component of the given type e.g. More... | |
MaxPoolingComponent : Maxpooling component was firstly used in ConvNet for selecting an representative activation in an area.
It inspired Maxout nonlinearity.
The input/output matrices are split to submatrices with width 'pool_stride_'. For instance, a minibatch of 512 frames is propagated by a convolutional layer, resulting in a 512 x 3840 input matrix for MaxpoolingComponent, which is composed of 128 feature maps for each frame (128 x 30). If you want a 3-to-1 maxpooling on each feature map, set 'pool_stride_' and 'pool_size_' as 128 and 3 respectively. Maxpooling component would create an output matrix of 512 x 1280. The 30 input neurons are grouped by a group size of 3, and the maximum in a group is selected, creating a smaller feature map of 10.
Our pooling does not supports overlaps, which simplifies the implementation (and was not helpful for Ossama).
Definition at line 468 of file nnet-component.h.
|
inlineexplicit |
Definition at line 472 of file nnet-component.h.
|
inline |
Definition at line 476 of file nnet-component.h.
|
virtual |
Perform backward pass propagation of the derivative, and also either update the model (if to_update == this) or update another model or compute the model derivative (otherwise).
Note: in_value and out_value are the values of the input and output of the component, and these may be dummy variables if respectively BackpropNeedsInput() or BackpropNeedsOutput() return false for that component (not all components need these).
num_chunks lets us treat the input matrix as contiguous-in-time chunks of equal size; it only matters if splicing is involved.
Implements Component.
Definition at line 4318 of file nnet-component.cc.
References CuMatrixBase< Real >::ColRange(), CuMatrixBase< Real >::EqualElementMask(), KALDI_ASSERT, kaldi::kSetZero, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), and CuMatrix< Real >::Resize().
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Copy component (deep copy).
Implements Component.
Definition at line 496 of file nnet-component.h.
|
virtual |
Reimplemented from Component.
Definition at line 4380 of file nnet-component.cc.
References Convolutional1dComponent::Type().
|
virtual |
Initialize, typically from a line of a config file.
The "args" will contain any parameters that need to be passed to the Component, e.g. dimensions.
Implements Component.
Definition at line 4269 of file nnet-component.cc.
References Convolutional1dComponent::Init(), KALDI_ERR, KALDI_LOG, kaldi::nnet2::ParseFromString(), and Convolutional1dComponent::Type().
Referenced by kaldi::nnet2::UnitTestMaxpoolingComponent().
|
inlinevirtual |
|
inlinevirtual |
Get size of output vectors.
Implements Component.
Definition at line 481 of file nnet-component.h.
References Component::Propagate().
|
virtual |
Perform forward pass propagation Input->Output.
Each row is one frame or training example. Interpreted as "num_chunks" equally sized chunks of frames; this only matters for layers that do things like context splicing. Typically this variable will either be 1 (when we're processing a single contiguous chunk of data) or will be the same as in.NumFrames(), but other values are possible if some layers do splicing.
Implements Component.
Definition at line 4295 of file nnet-component.cc.
References ChunkInfo::CheckSize(), CuMatrixBase< Real >::ColRange(), KALDI_ASSERT, ChunkInfo::NumChunks(), and CuMatrixBase< Real >::Set().
|
virtual |
Implements Component.
Definition at line 4355 of file nnet-component.cc.
References kaldi::nnet2::ExpectOneOrTwoTokens(), kaldi::ExpectToken(), and kaldi::ReadBasicType().
|
inlinevirtual |
Implements Component.
Definition at line 478 of file nnet-component.h.
|
virtual |
Write component to stream.
Implements Component.
Definition at line 4367 of file nnet-component.cc.
References kaldi::WriteBasicType(), and kaldi::WriteToken().
|
protected |
Definition at line 508 of file nnet-component.h.
|
protected |
Definition at line 509 of file nnet-component.h.
|
protected |
Definition at line 510 of file nnet-component.h.
|
protected |
Definition at line 511 of file nnet-component.h.