23 #ifndef KALDI_NNET_NNET_KL_HMM_H_ 24 #define KALDI_NNET_NNET_KL_HMM_H_ 66 row_sum.ApplyFloor(1e-20);
68 row_sum.InvertElements();
87 in_log_tmp.ApplyFloor(1e-20);
88 in_log_tmp.ApplyLog();
134 const std::vector<int32> &alignment) {
137 int32 num_frames = alignment.size();
138 for (
int32 i = 0;
i < num_frames;
i++) {
154 #endif // KALDI_NNET_NNET_KL_HMM_H_
void CopyFromMat(const MatrixBase< OtherReal > &src, MatrixTransposeType trans=kNoTrans)
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void PropagateFnc(const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out)
Abstract interface for propagation/backpropagation.
void Write(std::ostream &out, bool binary) const
write to stream.
void SetStats(const Matrix< BaseFloat > mat)
Set the statistics matrix.
int32 input_dim_
Data members,.
void CopyToMat(MatrixBase< OtherReal > *dst, MatrixTransposeType trans=kNoTrans) const
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
CuMatrix< BaseFloat > kl_inv_q_
void AddVecToCols(Real alpha, const CuVectorBase< Real > &col, Real beta=1.0)
(for each column c of *this), c = alpha * col + beta * c
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
void CopyFromMat(const MatrixBase< OtherReal > &M, MatrixTransposeType trans=kNoTrans)
Copy given matrix. (no resize is done).
ComponentType GetType() const
Get Type Identification of the component,.
ComponentType
Component type identification mechanism,.
void ReadData(std::istream &is, bool binary)
Reads the component content.
void Read(std::istream &in, bool binary, bool add=false)
read from stream.
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
void AddColSumMat(Real alpha, const CuMatrixBase< Real > &mat, Real beta=1.0)
Sum the columns of the matrix, add to vector.
void MulElements(const CuMatrixBase< Real > &A)
Multiply two matrices elementwise: C = C .* A.
void Accumulate(const Matrix< BaseFloat > &posteriors, const std::vector< int32 > &alignment)
Accumulate the statistics for KL-HMM paramter estimation,.
void AddMatMat(Real alpha, const CuMatrixBase< Real > &A, MatrixTransposeType transA, const CuMatrixBase< Real > &B, MatrixTransposeType transB, Real beta)
C = alpha * A(^T)*B(^T) + beta * C.
int32 output_dim_
Dimension of the output of the Component,.
void MulRowsVec(const VectorBase< Real > &scale)
Equivalent to (*this) = diag(scale) * (*this).
Matrix for CUDA computing.
MatrixIndexT NumCols() const
void InvertElements()
Inverts all the elements of the matrix.
A class representing a vector.
#define KALDI_ASSERT(cond)
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...)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero).
Abstract class, building block of the network.
KlHmm(int32 dim_in, int32 dim_out)
MatrixIndexT NumRows() const
Dimensions.
void AddColSumMat(Real alpha, const MatrixBase< Real > &M, Real beta=1.0)
Does *this = alpha * (sum of columns of M) + beta * *this.
void ApplyFloor(Real floor_val)
static bool ApproxEqual(float a, float b, float relative_tolerance=0.001)
return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)).
void WriteData(std::ostream &os, bool binary) const
Writes the component content.
Matrix< double > kl_stats_
Component * Copy() const
Copy component (deep copy),.