nnet-pdf-prior.h
Go to the documentation of this file.
1 // nnet/nnet-pdf-prior.h
2 
3 // Copyright 2013 Brno University of Technology (Author: Karel Vesely)
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 #ifndef KALDI_NNET_NNET_PDF_PRIOR_H_
21 #define KALDI_NNET_NNET_PDF_PRIOR_H_
22 
23 #include <cfloat>
24 #include <string>
25 
26 #include "base/kaldi-common.h"
27 #include "util/common-utils.h"
28 #include "matrix/matrix-lib.h"
29 #include "cudamatrix/cu-matrix.h"
30 #include "cudamatrix/cu-vector.h"
31 
32 namespace kaldi {
33 namespace nnet1 {
34 
36  std::string class_frame_counts;
39 
41  class_frame_counts(""),
42  prior_scale(1.0),
43  prior_floor(1e-10)
44  { }
45 
46  void Register(OptionsItf *opts) {
47  opts->Register("class-frame-counts", &class_frame_counts,
48  "Vector with frame-counts of pdfs to compute log-priors."
49  " (priors are typically subtracted from log-posteriors"
50  " or pre-softmax activations)");
51  opts->Register("prior-scale", &prior_scale,
52  "Scaling factor to be applied on pdf-log-priors");
53  opts->Register("prior-floor", &prior_floor,
54  "Flooring constatnt for prior probability "
55  "(i.e. label rel. frequency)");
56  }
57 };
58 
59 class PdfPrior {
60  public:
62  explicit PdfPrior(const PdfPriorOptions &opts);
63 
65  void SubtractOnLogpost(CuMatrixBase<BaseFloat> *llk);
66 
67  private:
70 
72 };
73 
74 } // namespace nnet1
75 } // namespace kaldi
76 
77 #endif // KALDI_NNET_NNET_PDF_PRIOR_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
CuVector< BaseFloat > log_priors_
#define KALDI_DISALLOW_COPY_AND_ASSIGN(type)
Definition: kaldi-utils.h:121
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
Matrix for CUDA computing.
Definition: matrix-common.h:69
void Register(OptionsItf *opts)