21 #ifndef KALDI_NNET_NNET_AFFINE_TRANSFORM_H_ 22 #define KALDI_NNET_NNET_AFFINE_TRANSFORM_H_ 49 float bias_mean = -2.0, bias_range = 2.0, param_stddev = 0.1;
52 while (is >> std::ws, !is.eof()) {
54 if (token ==
"<ParamStddev>")
ReadBasicType(is,
false, ¶m_stddev);
55 else if (token ==
"<BiasMean>")
ReadBasicType(is,
false, &bias_mean);
56 else if (token ==
"<BiasRange>")
ReadBasicType(is,
false, &bias_range);
60 else KALDI_ERR <<
"Unknown token " << token <<
", a typo in config?" 61 <<
" (ParamStddev|BiasMean|BiasRange|LearnRateCoef|BiasLearnRateCoef)";
77 while (
'<' ==
Peek(is, binary)) {
80 case 'L':
ExpectToken(is, binary,
"<LearnRateCoef>");
83 case 'B':
ExpectToken(is, binary,
"<BiasLearnRateCoef>");
100 bias_.Read(is, binary);
110 WriteToken(os, binary,
"<BiasLearnRateCoef>");
114 if (!binary) os <<
"\n";
117 bias_.Write(os, binary);
146 return std::string(
"\n linearity") +
154 return std::string(
"\n linearity_grad") +
223 bias_.CopyFromVec(bias);
247 #endif // KALDI_NNET_NNET_AFFINE_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,.
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 bias_learn_rate_coef_
Scalar applied to learning rate for bias (to be used in ::Update method),.
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 RandUniform(BaseFloat mu, BaseFloat range, CuMatrixBase< Real > *mat, struct RandomState *state=NULL)
Fill CuMatrix with random numbers (Uniform distribution): mu = the mean value, range = the 'width' of...
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...
void ApplyFloor(Real floor_val, MatrixIndexT *floored_count=NULL)
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 AddVecToRows(Real alpha, const CuVectorBase< Real > &row, Real beta=1.0)
(for each row r of *this), r = alpha * row + beta * r
void AddColSumMat(Real alpha, const CuMatrixBase< Real > &mat, Real beta=1.0)
Sum the columns of the matrix, add to vector.
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 MulElements(const CuMatrixBase< Real > &A)
Multiply two matrices elementwise: C = C .* A.
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 ApplyPow(Real power)
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)
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.
MatrixIndexT Dim() const
Dimensions.
Vector for CUDA computing.
SubVector< Real > Range(const MatrixIndexT o, const MatrixIndexT l)
Returns a sub-vector of a vector (a range of elements).