21 #ifndef KALDI_NNET_NNET_SENTENCE_AVERAGING_COMPONENT_H_    22 #define KALDI_NNET_NNET_SENTENCE_AVERAGING_COMPONENT_H_    65     while (is >> std::ws, !is.eof()) {
    70       else KALDI_ERR << 
"Unknown token " << token << 
", a typo in config?"    71                      << 
" (GradientBoost|Shrinkage|OnlySumming)";
    76     bool end_loop = 
false;
    77     while (!end_loop && 
'<' == 
Peek(is, binary)) {
    80         case 'G': 
ExpectToken(is, binary, 
"<GradientBoost>");
    92           } 
catch(
const std::exception &e) {
    93             KALDI_WARN << 
"ERROR was handled by exception!";
   193     std::string nested_nnet_filename;
   194     std::string nested_nnet_proto;
   197     while (is >> std::ws, !is.eof()) {
   199        if (token == 
"<NestedNnetFilename>") 
ReadToken(is, 
false, &nested_nnet_filename);
   200       else if (token == 
"<NestedNnetProto>") 
ReadToken(is, 
false, &nested_nnet_proto);
   201       else if (token == 
"<LearnRateFactor>") 
ReadBasicType(is, 
false, &learn_rate_factor_);
   202       else KALDI_ERR << 
"Unknown token " << token << 
" Typo in config?";
   205     KALDI_ASSERT((nested_nnet_proto != 
"") ^ (nested_nnet_filename != 
""));  
   206     if (nested_nnet_filename != 
"") nnet_.Read(nested_nnet_filename);
   207     if (nested_nnet_proto != 
"") nnet_.Init(nested_nnet_proto);
   214     nnet_.Read(is, binary);
   220     nnet_.Write(os, binary);
   232     nnet_.GetParams(¶ms_aux);
   241     return std::string(
"nested_network {\n") + nnet_.Info() + 
"}\n";
   245     return std::string(
"nested_gradient {\n") + nnet_.InfoGradient() + 
"}\n";
   252     nnet_.Propagate(in, &out_nnet);
   257       nnet_outputs = nnet_.OutputDim(),
   258       num_frames = out_nnet.
NumRows();
   261     average_row.
AddRowSumMat(1.0/num_frames, out_nnet, 0.0);
   263     out->
ColRange(0, nnet_outputs).AddVecToRows(1.0, average_row, 0.0);
   264     out->
ColRange(nnet_outputs, num_inputs).CopyFromMat(in);
   271     if (in_diff == NULL) 
return;
   273       nnet_outputs = nnet_.OutputDim();
   280     int32 nnet_outputs = nnet_.OutputDim(),
   294     nnet_.Backpropagate(nnet_out_diff, NULL);
   302     nnet_.SetTrainOptions(opts_);
   314 #endif  // KALDI_NNET_NNET_SENTENCE_AVERAGING_COMPONENT_H_ Deprecated!!!, keeping it as Katka Zmolikova used it in JSALT 2015. 
 
CuVector< BaseFloat > average_diff_
Auxiliary buffer for back-propagation (for average vector),. 
 
std::string ToString(const T &t)
Convert basic type to a string (please don't overuse),. 
 
void CopyFromMat(const MatrixBase< OtherReal > &src, MatrixTransposeType trans=kNoTrans)
 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
void InitData(std::istream &is)
Initialize the content of the component by the 'line' from the prototype,. 
 
virtual void SetTrainOptions(const NnetTrainOptions &opts)
Set the training options to the component,. 
 
std::string InfoGradient() const
Print some additional info about gradient (after <...> and dims),. 
 
void SetTrainOptions(const NnetTrainOptions &opts)
Set the training options to the component,. 
 
void PropagateFnc(const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out)
Abstract interface for propagation/backpropagation. 
 
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...) 
 
CuVector< BaseFloat > average_row_
Auxiliary buffer for forward propagation (for average vector),. 
 
~SimpleSentenceAveragingComponent()
 
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...
 
Class UpdatableComponent is a Component which has trainable parameters, it contains SGD training hype...
 
void ReadData(std::istream &is, bool binary)
Reads the component content. 
 
ComponentType GetType() const
Get Type Identification of the component,. 
 
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...
 
int32 NumParams() const
Number of trainable parameters,. 
 
void Update(const CuMatrixBase< BaseFloat > &input, const CuMatrixBase< BaseFloat > &diff)
Compute gradient and update parameters,. 
 
int Peek(std::istream &is, bool binary)
Peek consumes whitespace (if binary == false) and then returns the peek() value of the stream...
 
Component * Copy() const
Copy component (deep copy),. 
 
std::string InfoGradient() const
Print some additional info about gradient (after <...> and dims),. 
 
ComponentType
Component type identification mechanism,. 
 
void PropagateFnc(const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out)
Abstract interface for propagation/backpropagation. 
 
void WriteData(std::ostream &os, bool binary) const
Writes the component content. 
 
bool only_summing_
Removes normalization term from arithmetic mean (when true). 
 
void CopyFromVec(const VectorBase< Real > &v)
Copy data from another vector (must match own size). 
 
std::string Info() const
Print some additional info (after <ComponentName> and the dims),. 
 
void AddVecToRows(Real alpha, const CuVectorBase< Real > &row, Real beta=1.0)
(for each row r of *this), r = alpha * row + beta * r 
 
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,. 
 
std::string Info() const
Print some additional info (after <ComponentName> and the dims),. 
 
int32 InputDim() const
Get the dimension of the input,. 
 
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. 
 
~SentenceAveragingComponent()
 
SimpleSentenceAveragingComponent(int32 dim_in, int32 dim_out)
 
CuSubMatrix< Real > ColRange(const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
 
BaseFloat gradient_boost_
Scalar applied on gradient in backpropagation,. 
 
Matrix for CUDA computing. 
 
MatrixIndexT NumCols() const
 
void ReadData(std::istream &is, bool binary)
Reads the component content. 
 
A class representing a vector. 
 
#define KALDI_ASSERT(cond)
 
void GetGradient(VectorBase< BaseFloat > *gradient) const
Get gradient reshaped as a vector,. 
 
void GetParams(VectorBase< BaseFloat > *params) const
Get the trainable parameters reshaped as a vector,. 
 
void WriteData(std::ostream &os, bool binary) const
Writes the component content. 
 
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. 
 
SentenceAveragingComponent(int32 dim_in, int32 dim_out)
 
int32 OutputDim() const
Get the dimension of the output,. 
 
void SetParams(const VectorBase< BaseFloat > ¶ms)
Set the trainable parameters from, reshaped as a vector,. 
 
MatrixIndexT NumRows() const
Dimensions. 
 
Provides a vector abstraction class. 
 
Component * Copy() const
Copy component (deep copy),. 
 
SimpleSentenceAveragingComponent does not have nested network, it is intended to be used inside of a ...
 
BaseFloat shrinkage_
Number of 'imaginary' zero-vectors in the average (shrinks the average vector for short sentences)...
 
void AddRowSumMat(Real alpha, const CuMatrixBase< Real > &mat, Real beta=1.0)
Sum the rows of the matrix, add to vector. 
 
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...)