21 #ifndef KALDI_NNET_NNET_LINEAR_TRANSFORM_H_ 22 #define KALDI_NNET_NNET_LINEAR_TRANSFORM_H_ 49 float param_stddev = 0.1;
50 std::string read_matrix_file;
53 while (is >> std::ws, !is.eof()) {
55 if (token ==
"<ParamStddev>")
ReadBasicType(is,
false, ¶m_stddev);
56 else if (token ==
"<ReadMatrix>")
ReadToken(is,
false, &read_matrix_file);
58 else KALDI_ERR <<
"Unknown token " << token <<
", a typo in config?" 59 <<
" (ParamStddev|ReadMatrix|LearnRateCoef)";
62 if (read_matrix_file !=
"") {
64 Input in(read_matrix_file, &binary);
70 KALDI_ERR <<
"Dimensionality mismatch! Expected matrix" 72 <<
", loaded matrix " << read_matrix_file
76 KALDI_LOG <<
"Loaded <LinearTransform> matrix from file : " 91 while (
'<' ==
Peek(is, binary)) {
94 case 'L':
ExpectToken(is, binary,
"<LearnRateCoef>");
115 if (!binary) os <<
"\n";
145 return std::string(
"\n linearity") +
150 return std::string(
"\n linearity_grad") +
212 #endif // KALDI_NNET_NNET_LINEAR_TRANSFORM_H_ std::string ToString(const T &t)
Convert basic type to a string (please don't overuse),.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
NnetTrainOptions opts_
Option-class with training hyper-parameters,.
std::string MomentStatistics(const VectorBase< Real > &vec)
Get a string with statistics of the data in a vector, so we can print them easily.
int32 input_dim_
Data members,.
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Base class which provides matrix operations not involving resizing or allocation. ...
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...
BaseFloat learn_rate_coef_
Scalar applied to learning rate for weight matrices (to be used in ::Update method),.
Class UpdatableComponent is a Component which has trainable parameters, it contains SGD training hype...
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...
int Peek(std::istream &is, bool binary)
Peek consumes whitespace (if binary == false) and then returns the peek() value of the stream...
ComponentType
Component type identification mechanism,.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
int32 InputDim() const
Get the dimension of the input,.
void RandGauss(BaseFloat mu, BaseFloat sigma, CuMatrixBase< Real > *mat, struct RandomState *state=NULL)
Fill CuMatrix with random numbers (Gaussian distribution): mu = the mean value, sigma = standard devi...
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.
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
MatrixIndexT Dim() const
Returns the dimension of the vector.
int PeekToken(std::istream &is, bool binary)
PeekToken will return the first character of the next token, or -1 if end of file.
int32 output_dim_
Dimension of the output of the Component,.
Matrix for CUDA computing.
MatrixIndexT NumCols() const
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void CopyRowsFromMat(const MatrixBase< Real > &M)
Performs a row stack of the matrix M.
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.
int32 OutputDim() const
Get the dimension of the output,.
MatrixIndexT NumRows() const
Dimensions.
Provides a vector abstraction class.
void RegularizeL1(CuMatrixBase< Real > *weight, CuMatrixBase< Real > *grad, Real l1, Real lr)
RegularizeL1 is a gradient step with l1 regularization added to the gradient.