Splices a context window of frames together [over time]. More...
#include <nnet-component.h>
Public Member Functions | |
SpliceComponent () | |
void | Init (int32 input_dim, std::vector< int32 > context, int32 const_component_dim=0) |
virtual std::string | Type () const |
virtual std::string | Info () 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 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... | |
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 > &out_value, 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... | |
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) |
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 () |
Private Member Functions | |
KALDI_DISALLOW_COPY_AND_ASSIGN (SpliceComponent) | |
Private Attributes | |
int32 | input_dim_ |
std::vector< int32 > | context_ |
int32 | const_component_dim_ |
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... | |
Splices a context window of frames together [over time].
Definition at line 1092 of file nnet-component.h.
|
inline |
Definition at line 1094 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 2662 of file nnet-component.cc.
References ChunkInfo::Check(), ChunkInfo::CheckSize(), ChunkInfo::ChunkSize(), CuMatrixBase< Real >::CopyRows(), ChunkInfo::GetIndex(), ChunkInfo::GetOffset(), AffineComponent::InputDim(), KALDI_ASSERT, kaldi::kUndefined, ChunkInfo::NumChunks(), ChunkInfo::NumCols(), CuMatrixBase< Real >::NumCols(), ChunkInfo::NumRows(), CuMatrixBase< Real >::NumRows(), AffineComponent::OutputDim(), and CuMatrix< Real >::Resize().
|
inlinevirtual |
Reimplemented from Component.
Definition at line 1119 of file nnet-component.h.
|
inlinevirtual |
Reimplemented from Component.
Definition at line 1120 of file nnet-component.h.
References kaldi::cu::Copy(), and KALDI_DISALLOW_COPY_AND_ASSIGN.
|
inlinevirtual |
Return a vector describing the temporal context this component requires for each frame of output, as a sorted list.
The default implementation returns a vector ( 0 ), but a splicing layer might return e.g. (-2, -1, 0, 1, 2), but it doesn't have to be contiguous. Note : The context needed by the entire network is a function of the contexts needed by all the components. It is required that Context().front() <= 0 and Context().back() >= 0.
Reimplemented from Component.
Definition at line 1106 of file nnet-component.h.
References Component::Propagate().
|
virtual |
Copy component (deep copy).
Implements Component.
Definition at line 2760 of file nnet-component.cc.
References SpliceComponent::const_component_dim_, SpliceComponent::context_, and SpliceComponent::input_dim_.
|
virtual |
Reimplemented from Component.
Definition at line 2463 of file nnet-component.cc.
References Component::Info().
Definition at line 2475 of file nnet-component.cc.
References kaldi::IsSortedAndUniq(), and KALDI_ASSERT.
Referenced by kaldi::ConvertSpliceComponent(), kaldi::nnet2::GenRandomNnet(), and kaldi::nnet2::UnitTestSpliceComponent().
|
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 2488 of file nnet-component.cc.
References rnnlm::i, AffineComponentPreconditionedOnline::Init(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet2::ParseFromString(), and AffineComponentPreconditionedOnline::Type().
|
inlinevirtual |
|
private |
|
virtual |
Get size of output vectors.
Implements Component.
Definition at line 2513 of file nnet-component.cc.
|
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 2577 of file nnet-component.cc.
References ChunkInfo::Check(), ChunkInfo::CheckSize(), ChunkInfo::ChunkSize(), ChunkInfo::GetIndex(), ChunkInfo::GetOffset(), KALDI_ASSERT, KALDI_ERR, ChunkInfo::NumChunks(), ChunkInfo::NumCols(), CuMatrixBase< Real >::NumCols(), and CuMatrixBase< Real >::NumRows().
|
virtual |
Implements Component.
Definition at line 2768 of file nnet-component.cc.
References kaldi::nnet2::ExpectOneOrTwoTokens(), kaldi::ExpectToken(), rnnlm::i, KALDI_ERR, kaldi::ReadBasicType(), kaldi::ReadIntegerVector(), and kaldi::ReadToken().
|
inlinevirtual |
Implements Component.
Definition at line 1101 of file nnet-component.h.
|
virtual |
Write component to stream.
Implements Component.
Definition at line 2793 of file nnet-component.cc.
References kaldi::WriteBasicType(), kaldi::WriteIntegerVector(), and kaldi::WriteToken().
|
private |
Definition at line 1128 of file nnet-component.h.
Referenced by SpliceComponent::Copy().
|
private |
Definition at line 1127 of file nnet-component.h.
Referenced by SpliceComponent::Copy().
|
private |
Definition at line 1126 of file nnet-component.h.
Referenced by SpliceComponent::Copy().