ChunkInfo is a class whose purpose is to describe the structure of matrices holding features. More...
#include <nnet-component.h>
Public Member Functions | |
ChunkInfo () | |
ChunkInfo (int32 feat_dim, int32 num_chunks, int32 first_offset, int32 last_offset) | |
ChunkInfo (int32 feat_dim, int32 num_chunks, const std::vector< int32 > offsets) | |
int32 | GetIndex (int32 offset) const |
int32 | GetOffset (int32 index) const |
void | MakeOffsetsContiguous () |
int32 | ChunkSize () const |
int32 | NumChunks () const |
int32 | NumRows () const |
Returns the number of rows that we expect the feature matrix to have. More... | |
int32 | NumCols () const |
Returns the number of columns that we expect the feature matrix to have. More... | |
void | CheckSize (const CuMatrixBase< BaseFloat > &mat) const |
Checks that the matrix has the size we expect, and die if not. More... | |
void | Check () const |
Checks that the data in the ChunkInfo is valid, and die if not. More... | |
Private Attributes | |
int32 | feat_dim_ |
int32 | num_chunks_ |
int32 | first_offset_ |
int32 | last_offset_ |
std::vector< int32 > | offsets_ |
ChunkInfo is a class whose purpose is to describe the structure of matrices holding features.
This is useful mostly in training time. The main reason why we have this is to support efficient training for networks which we have splicing components that splice in a non-contiguous way, e.g. frames -5, 0 and 5. We also have in mind future extensibility to convnets which might have similar issues. This class describes the structure of a minibatch of features, or of a single contiguous block of features. Examples are as follows, and offsets is empty if not mentioned: When decoding, at input to the network: feat_dim = 13, num_chunks = 1, first_offset = 0, last_offset = 691 and in the middle of the network (assuming splicing is +-7): feat_dim = 1024, num_chunks = 1, first_offset = 7, last_offset = 684 When training, at input to the network: feat_dim = 13, num_chunks = 512, first_offset = 0, last_offset= 14 and in the middle of the network: feat_dim = 1024, num_chunks = 512, first_offset = 7, last_offset = 7 The only situation where offsets would be nonempty would be if we do splicing with gaps in. E.g. suppose at network input we splice +-2 frames (contiguous) and somewhere in the middle we splice frames {-5, 0, 5}, then we would have the following while training At input to the network: feat_dim = 13, num_chunks = 512, first_offset = 0, last_offset = 14 After the first hidden layer: feat_dim = 1024, num_chunks = 512, first_offset = 2, last_offset = 12, offsets = {2, 10, 12} At the output of the last hidden layer (after the {-5, 0, 5} splice): feat_dim = 1024, num_chunks = 512, first_offset = 7, last_offset = 7 (the decoding setup would still look pretty normal, so we don't give an example).
Definition at line 72 of file nnet-component.h.
|
inline |
Definition at line 74 of file nnet-component.h.
Definition at line 79 of file nnet-component.h.
References ChunkInfo::Check().
Definition at line 85 of file nnet-component.h.
References ChunkInfo::Check(), ChunkInfo::first_offset_, ChunkInfo::GetIndex(), ChunkInfo::GetOffset(), ChunkInfo::last_offset_, and ChunkInfo::offsets_.
void Check | ( | ) | const |
Checks that the data in the ChunkInfo is valid, and die if not.
Definition at line 2543 of file nnet-component.cc.
References KALDI_ASSERT.
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), ChunkInfo::ChunkInfo(), ChunkInfo::MakeOffsetsContiguous(), ChunkInfo::NumCols(), SpliceComponent::Propagate(), and SpliceMaxComponent::Propagate().
void CheckSize | ( | const CuMatrixBase< BaseFloat > & | mat | ) | const |
Checks that the matrix has the size we expect, and die if not.
Definition at line 2559 of file nnet-component.cc.
References KALDI_ASSERT, CuMatrixBase< Real >::NumCols(), and CuMatrixBase< Real >::NumRows().
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), ChunkInfo::NumCols(), MaxoutComponent::Propagate(), MaxpoolingComponent::Propagate(), PnormComponent::Propagate(), SigmoidComponent::Propagate(), TanhComponent::Propagate(), PowerComponent::Propagate(), SoftHingeComponent::Propagate(), SoftmaxComponent::Propagate(), LogSoftmaxComponent::Propagate(), AffineComponent::Propagate(), SpliceComponent::Propagate(), SpliceMaxComponent::Propagate(), BlockAffineComponent::Propagate(), SumGroupComponent::Propagate(), PermuteComponent::Propagate(), DctComponent::Propagate(), FixedLinearComponent::Propagate(), FixedAffineComponent::Propagate(), DropoutComponent::Propagate(), and Convolutional1dComponent::Propagate().
|
inline |
Definition at line 115 of file nnet-component.h.
References ChunkInfo::num_chunks_, and ChunkInfo::NumRows().
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), SpliceComponent::Propagate(), and SpliceMaxComponent::Propagate().
Definition at line 2519 of file nnet-component.cc.
References KALDI_ASSERT.
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), ChunkInfo::ChunkInfo(), SpliceComponent::Propagate(), and SpliceMaxComponent::Propagate().
Definition at line 2532 of file nnet-component.cc.
References KALDI_ASSERT.
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), ChunkInfo::ChunkInfo(), SpliceComponent::Propagate(), and SpliceMaxComponent::Propagate().
|
inline |
Definition at line 111 of file nnet-component.h.
References ChunkInfo::Check(), and ChunkInfo::offsets_.
|
inline |
Definition at line 118 of file nnet-component.h.
References ChunkInfo::num_chunks_.
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), MaxoutComponent::Propagate(), MaxpoolingComponent::Propagate(), PnormComponent::Propagate(), SigmoidComponent::Propagate(), TanhComponent::Propagate(), PowerComponent::Propagate(), SoftHingeComponent::Propagate(), SoftmaxComponent::Propagate(), LogSoftmaxComponent::Propagate(), AffineComponent::Propagate(), SpliceComponent::Propagate(), SpliceMaxComponent::Propagate(), BlockAffineComponent::Propagate(), SumGroupComponent::Propagate(), PermuteComponent::Propagate(), FixedLinearComponent::Propagate(), FixedAffineComponent::Propagate(), DropoutComponent::Propagate(), and Convolutional1dComponent::Propagate().
|
inline |
Returns the number of columns that we expect the feature matrix to have.
Definition at line 126 of file nnet-component.h.
References ChunkInfo::Check(), ChunkInfo::CheckSize(), and ChunkInfo::feat_dim_.
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), Component::Propagate(), SpliceComponent::Propagate(), SpliceMaxComponent::Propagate(), DctComponent::Propagate(), and kaldi::nnet2::UnitTestGenericComponentInternal().
|
inline |
Returns the number of rows that we expect the feature matrix to have.
Definition at line 121 of file nnet-component.h.
References ChunkInfo::first_offset_, ChunkInfo::last_offset_, ChunkInfo::num_chunks_, and ChunkInfo::offsets_.
Referenced by SpliceComponent::Backprop(), SpliceMaxComponent::Backprop(), ChunkInfo::ChunkSize(), Component::Propagate(), DctComponent::Propagate(), and kaldi::nnet2::UnitTestGenericComponentInternal().
|
private |
Definition at line 135 of file nnet-component.h.
Referenced by ChunkInfo::NumCols().
|
private |
Definition at line 137 of file nnet-component.h.
Referenced by ChunkInfo::ChunkInfo(), and ChunkInfo::NumRows().
|
private |
Definition at line 140 of file nnet-component.h.
Referenced by ChunkInfo::ChunkInfo(), and ChunkInfo::NumRows().
|
private |
Definition at line 136 of file nnet-component.h.
Referenced by ChunkInfo::ChunkSize(), ChunkInfo::NumChunks(), and ChunkInfo::NumRows().
|
private |
Definition at line 141 of file nnet-component.h.
Referenced by ChunkInfo::ChunkInfo(), ChunkInfo::MakeOffsetsContiguous(), and ChunkInfo::NumRows().