21 #ifndef KALDI_NNET_NNET_AVERAGE_POOLING_COMPONENT_H_ 22 #define KALDI_NNET_NNET_AVERAGE_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.AddMat(1.0, in.
ColRange(p*pool_stride_, pool_stride_));
118 pool.Scale(1.0 / pool_size_);
132 std::vector<int32> patch_summands(num_patches, 0);
139 for (
int32 q = 0; q < num_pools; q++) {
145 patch_summands[p] += 1;
153 for (
int32 p = 0; p < num_patches; p++) {
156 tgt.Scale(1.0/patch_summands[p]);
169 #endif // KALDI_NNET_NNET_AVERAGE_POOLING_COMPONENT_H_ This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
AveragePoolingComponent(int32 dim_in, int32 dim_out)
int32 input_dim_
Data members,.
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...
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
void AddMat(Real alpha, const CuMatrixBase< Real > &A, MatrixTransposeType trans=kNoTrans)
*this += alpha * A
ComponentType
Component type identification mechanism,.
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 WriteData(std::ostream &os, bool binary) const
Writes the component content.
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. ...
void InitData(std::istream &is)
Virtual interface for initialization and I/O,.
Component * Copy() const
Copy component (deep copy),.
void ReadData(std::istream &is, bool binary)
Reads the component content.
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
Matrix for CUDA computing.
#define KALDI_ASSERT(cond)
ComponentType GetType() const
Get Type Identification of the component,.
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.
AveragePoolingComponent : The input/output matrices are split to submatrices with width 'pool_stride_...
~AveragePoolingComponent()