Sgmm2FmllrGlobalParams Class Reference

Global adaptation parameters. More...

#include <fmllr-sgmm2.h>

Collaboration diagram for Sgmm2FmllrGlobalParams:

Public Member Functions

void Init (const AmSgmm2 &sgmm, const Vector< BaseFloat > &state_occs)
 
void Write (std::ostream &out_stream, bool binary) const
 
void Read (std::istream &in_stream, bool binary)
 
bool IsEmpty () const
 
bool HasBasis () const
 

Public Attributes

Matrix< BaseFloatpre_xform_
 Pre-transform matrix. Dim is [D][D+1]. More...
 
Matrix< BaseFloatinv_xform_
 Inverse of pre-transform. Dim is [D][D+1]. More...
 
Vector< BaseFloatmean_scatter_
 Diagonal of mean-scatter matrix. Dim is [D]. More...
 
std::vector< Matrix< BaseFloat > > fmllr_bases_
 {W}_b. [b][d][d], dim is [B][D][D+1]. More...
 

Detailed Description

Global adaptation parameters.

Definition at line 91 of file fmllr-sgmm2.h.

Member Function Documentation

◆ HasBasis()

bool HasBasis ( ) const
inline

Definition at line 100 of file fmllr-sgmm2.h.

Referenced by FmllrSgmm2Accs::Update().

100 { return fmllr_bases_.size() != 0; }
std::vector< Matrix< BaseFloat > > fmllr_bases_
{W}_b. [b][d][d], dim is [B][D][D+1].
Definition: fmllr-sgmm2.h:109

◆ Init()

void Init ( const AmSgmm2 sgmm,
const Vector< BaseFloat > &  state_occs 
)
inline

Definition at line 112 of file fmllr-sgmm2.h.

References AmSgmm2::ComputeFmllrPreXform().

113  {
114  sgmm.ComputeFmllrPreXform(state_occs, &pre_xform_, &inv_xform_,
115  &mean_scatter_);
116 }
Matrix< BaseFloat > pre_xform_
Pre-transform matrix. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:103
Matrix< BaseFloat > inv_xform_
Inverse of pre-transform. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:105
Vector< BaseFloat > mean_scatter_
Diagonal of mean-scatter matrix. Dim is [D].
Definition: fmllr-sgmm2.h:107

◆ IsEmpty()

bool IsEmpty ( ) const
inline

Definition at line 96 of file fmllr-sgmm2.h.

Referenced by FmllrSgmm2Accs::Update().

96  {
97  return (pre_xform_.NumRows() == 0 || inv_xform_.NumRows() == 0 ||
98  mean_scatter_.Dim() == 0);
99  }
Matrix< BaseFloat > pre_xform_
Pre-transform matrix. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:103
Matrix< BaseFloat > inv_xform_
Inverse of pre-transform. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:105
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
Vector< BaseFloat > mean_scatter_
Diagonal of mean-scatter matrix. Dim is [D].
Definition: fmllr-sgmm2.h:107

◆ Read()

void Read ( std::istream &  in_stream,
bool  binary 
)

Definition at line 122 of file fmllr-sgmm2.cc.

References kaldi::ExpectToken(), Sgmm2FmllrGlobalParams::fmllr_bases_, rnnlm::i, Sgmm2FmllrGlobalParams::inv_xform_, KALDI_ERR, Sgmm2FmllrGlobalParams::mean_scatter_, Sgmm2FmllrGlobalParams::pre_xform_, Matrix< Real >::Read(), kaldi::ReadBasicType(), and kaldi::ReadToken().

Referenced by main().

122  {
123  ExpectToken(in, binary, "<SGMM_FMLLR_GLOBAL_PARAMS>");
124  ExpectToken(in, binary, "<PRE_XFORM>");
125  pre_xform_.Read(in, binary);
126  ExpectToken(in, binary, "<INV_XFORM>");
127  inv_xform_.Read(in, binary);
128  ExpectToken(in, binary, "<MEAN_SCATTER>");
129  mean_scatter_.Read(in, binary);
130  std::string token;
131  ReadToken(in, binary, &token);
132  if (token == "<FMLLR_BASIS>") {
133  uint32 tmp;
134  ReadBasicType(in, binary, &tmp);
135  fmllr_bases_.resize(tmp);
136  for (uint32 i = 0; i < tmp; i++) {
137  fmllr_bases_[i].Read(in, binary);
138  }
139  } else {
140  if (token != "</SGMM_FMLLR_GLOBAL_PARAMS>")
141  KALDI_ERR << "Unexpected token '" << token << "' found.";
142  }
143 }
Matrix< BaseFloat > pre_xform_
Pre-transform matrix. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:103
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...
Definition: io-funcs-inl.h:55
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
Definition: io-funcs.cc:154
void Read(std::istream &in, bool binary, bool add=false)
read from stream.
Matrix< BaseFloat > inv_xform_
Inverse of pre-transform. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:105
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
Definition: io-funcs.cc:191
#define KALDI_ERR
Definition: kaldi-error.h:147
Vector< BaseFloat > mean_scatter_
Diagonal of mean-scatter matrix. Dim is [D].
Definition: fmllr-sgmm2.h:107
std::vector< Matrix< BaseFloat > > fmllr_bases_
{W}_b. [b][d][d], dim is [B][D][D+1].
Definition: fmllr-sgmm2.h:109

◆ Write()

void Write ( std::ostream &  out_stream,
bool  binary 
) const

Definition at line 103 of file fmllr-sgmm2.cc.

References Sgmm2FmllrGlobalParams::fmllr_bases_, rnnlm::i, Sgmm2FmllrGlobalParams::inv_xform_, Sgmm2FmllrGlobalParams::mean_scatter_, Sgmm2FmllrGlobalParams::pre_xform_, MatrixBase< Real >::Write(), kaldi::WriteBasicType(), and kaldi::WriteToken().

Referenced by main().

103  {
104  WriteToken(out, binary, "<SGMM_FMLLR_GLOBAL_PARAMS>");
105  WriteToken(out, binary, "<PRE_XFORM>");
106  pre_xform_.Write(out, binary);
107  WriteToken(out, binary, "<INV_XFORM>");
108  inv_xform_.Write(out, binary);
109  WriteToken(out, binary, "<MEAN_SCATTER>");
110  mean_scatter_.Write(out, binary);
111  if (fmllr_bases_.size() != 0) {
112  WriteToken(out, binary, "<FMLLR_BASIS>");
113  uint32 tmp = static_cast<uint32>(fmllr_bases_.size());
114  WriteBasicType(out, binary, tmp);
115  for (uint32 i = 0; i < tmp; i++) {
116  fmllr_bases_[i].Write(out, binary);
117  }
118  }
119  WriteToken(out, binary, "</SGMM_FMLLR_GLOBAL_PARAMS>");
120 }
void Write(std::ostream &out, bool binary) const
write to stream.
Matrix< BaseFloat > pre_xform_
Pre-transform matrix. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:103
Matrix< BaseFloat > inv_xform_
Inverse of pre-transform. Dim is [D][D+1].
Definition: fmllr-sgmm2.h:105
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134
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...
Definition: io-funcs-inl.h:34
Vector< BaseFloat > mean_scatter_
Diagonal of mean-scatter matrix. Dim is [D].
Definition: fmllr-sgmm2.h:107
std::vector< Matrix< BaseFloat > > fmllr_bases_
{W}_b. [b][d][d], dim is [B][D][D+1].
Definition: fmllr-sgmm2.h:109

Member Data Documentation

◆ fmllr_bases_

std::vector< Matrix<BaseFloat> > fmllr_bases_

{W}_b. [b][d][d], dim is [B][D][D+1].

Definition at line 109 of file fmllr-sgmm2.h.

Referenced by kaldi::EstimateSgmm2FmllrSubspace(), Sgmm2FmllrGlobalParams::Read(), FmllrSgmm2Accs::Update(), and Sgmm2FmllrGlobalParams::Write().

◆ inv_xform_

◆ mean_scatter_

◆ pre_xform_


The documentation for this class was generated from the following files: