get-feature-transform.h
Go to the documentation of this file.
1 // nnet2/get-feature-transform.h
2 
3 // Copyright 2009-2011 Jan Silovsky
4 // 2013 Johns Hopkins University (author: Daniel Povey)
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 
21 #ifndef KALDI_NNET2_GET_FEATURE_TRANSFORM_H_
22 #define KALDI_NNET2_GET_FEATURE_TRANSFORM_H_
23 
24 #include "base/kaldi-common.h"
25 #include "util/common-utils.h"
26 #include "matrix/matrix-lib.h"
27 #include "transform/lda-estimate.h"
28 
29 namespace kaldi {
30 
44  FeatureTransformEstimateOptions(): remove_offset(true), dim(-1),
45  within_class_factor(0.001), max_singular_value(5.0) { }
46 
47  void Register(OptionsItf *opts) {
48  opts->Register("remove-offset", &remove_offset, "If true, output an affine "
49  "transform that makes the projected data mean equal to zero.");
50  opts->Register("dim", &dim, "Dimension to project to with LDA");
51  opts->Register("within-class-factor", &within_class_factor, "If 1.0, do "
52  "conventional LDA where the within-class variance will be "
53  "unit in the projected space. May be set to less than 1.0, "
54  "which scales the features to have less variance, particularly "
55  "for dimensions where between-class variance is small. ");
56  opts->Register("max-singular-value", &max_singular_value, "If >0, maximum "
57  "allowed singular value of final transform (they are floored "
58  "to this)");
59  }
60 };
61 
134  public:
144  void Estimate(const FeatureTransformEstimateOptions &opts,
146  TpMatrix<BaseFloat> *within_cholesky) const;
147  protected:
148  static void EstimateInternal(const FeatureTransformEstimateOptions &opts,
149  const SpMatrix<double> &total_covar,
150  const SpMatrix<double> &between_covar,
151  const Vector<double> &mean,
154 };
155 
156 
158  public:
162  void Estimate(const FeatureTransformEstimateOptions &opts,
163  const std::vector<std::vector<int32> > &indexes,
164  Matrix<BaseFloat> *M) const;
165 
166  private:
167  void EstimateTransformPart(const FeatureTransformEstimateOptions &opts,
168  const std::vector<int32> &indexes,
169  const SpMatrix<double> &total_covar,
170  const SpMatrix<double> &between_covar,
171  const Vector<double> &mean,
172  Matrix<BaseFloat> *M) const;
173 };
174 
175 
176 
177 } // End namespace kaldi
178 
179 #endif // KALDI_NNET2_GET_FEATURE_TRANSFORM_H_
180 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
Class for computing linear discriminant analysis (LDA) transform.
Definition: lda-estimate.h:57
kaldi::int32 int32
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
Packed symetric matrix class.
Definition: matrix-common.h:63
Class for computing a feature transform used for preconditioning of the training data in neural-netwo...