21 #ifndef KALDI_NNET_NNET_MAX_POOLING_COMPONENT_H_ 22 #define KALDI_NNET_NNET_MAX_POOLING_COMPONENT_H_ 58 while (is >> std::ws, !is.eof()) {
63 else KALDI_ERR <<
"Unknown token " << token <<
", a typo in config?" 64 <<
" (PoolSize|PoolStep|PoolStride)";
93 void WriteData(std::ostream &os,
bool binary)
const {
110 for (
int32 q = 0; q < num_pools; q++) {
116 pool.Max(in.
ColRange(p*pool_stride_, pool_stride_));
131 std::vector<int32> patch_summands(num_patches, 0);
138 for (
int32 q = 0; q<num_pools; q++) {
152 src.MulElements(mask);
153 tgt.AddMat(1.0, src);
155 patch_summands[p] += 1;
160 for (
int32 p = 0; p < num_patches; p++) {
163 tgt.Scale(1.0/patch_summands[p]);
176 #endif // KALDI_NNET_NNET_MAX_POOLING_COMPONENT_H_ This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void WriteData(std::ostream &os, bool binary) const
Writes the component content.
void ReadData(std::istream &is, bool binary)
Reads the component content.
void InitData(std::istream &is)
Virtual interface for initialization and I/O,.
MaxPoolingComponent : The input/output matrices are split to submatrices with width 'pool_stride_'...
int32 input_dim_
Data members,.
void BackpropagateFnc(const CuMatrixBase< BaseFloat > &in, const CuMatrixBase< BaseFloat > &out, const CuMatrixBase< BaseFloat > &out_diff, CuMatrixBase< BaseFloat > *in_diff)
Backward pass transformation (to be implemented by descending class...)
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
Component * Copy() const
Copy component (deep copy),.
ComponentType GetType() const
Get Type Identification of the component,.
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
ComponentType
Component type identification mechanism,.
void PropagateFnc(const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out)
Abstract interface for propagation/backpropagation.
void SetZero()
Math operations, some calling kernels.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
This class is used for a piece of a CuMatrix.
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
int32 output_dim_
Dimension of the output of the Component,.
CuSubMatrix< Real > ColRange(const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
MaxPoolingComponent(int32 dim_in, int32 dim_out)
Matrix for CUDA computing.
#define KALDI_ASSERT(cond)
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
Abstract class, building block of the network.
void EqualElementMask(const CuMatrixBase< Real > &mat, CuMatrix< Real > *mask) const