combine-nnet.h
Go to the documentation of this file.
1 // nnet2/combine-nnet.h
2 
3 // Copyright 2012 Johns Hopkins University (author: Daniel Povey)
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_NNET2_COMBINE_NNET_H_
21 #define KALDI_NNET2_COMBINE_NNET_H_
22 
23 #include "nnet2/nnet-update.h"
24 #include "nnet2/nnet-compute.h"
25 #include "util/parse-options.h"
26 #include "itf/options-itf.h"
27 
28 namespace kaldi {
29 namespace nnet2 {
30 
36  int32 initial_model; // If provided, the index of the initial model to start
37  // the optimization from.
38  int32 num_bfgs_iters; // The dimension is small (e.g. 3 to 5 times the
39  // number of neural nets we were given, e.g. 10) so we do
40  // BFGS. We actually implement this as L-BFGS but setting the number of
41  // vectors to be the same as the dimension of the space. Note: this
42  // num-iters is in reality the number of function evaluations.
43 
46  NnetCombineConfig(): initial_model(-1), num_bfgs_iters(30),
47  initial_impr(0.01),
48  test_gradient(false) { }
49 
50  void Register(OptionsItf *opts) {
51  opts->Register("initial-model", &initial_model, "Specifies where to start the "
52  "optimization from. If 0 ... #models-1, then specifies the model; "
53  "if #models, then the average of all inputs; otherwise, chosen "
54  "automatically from the previous options.");
55  opts->Register("num-bfgs-iters", &num_bfgs_iters, "Maximum number of function "
56  "evaluations for BFGS to use when optimizing combination weights");
57  opts->Register("initial-impr", &initial_impr, "Amount of objective-function change "
58  "we aim for on the first iteration.");
59  opts->Register("test-gradient", &test_gradient, "If true, activate code that "
60  "tests the gradient is accurate.");
61  }
62 };
63 
64 void CombineNnets(const NnetCombineConfig &combine_config,
65  const std::vector<NnetExample> &validation_set,
66  const std::vector<Nnet> &nnets_in,
67  Nnet *nnet_out);
68 
69 
70 
71 } // namespace nnet2
72 } // namespace kaldi
73 
74 #endif
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
kaldi::int32 int32
void Register(OptionsItf *opts)
Definition: combine-nnet.h:50
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
Configuration class that controls neural net combination, where we combine a number of neural nets...
Definition: combine-nnet.h:35
This header provides functionality for sample-by-sample stochastic gradient descent and gradient comp...
static void CombineNnets(const Vector< BaseFloat > &scale_params, const std::vector< Nnet > &nnets, Nnet *dest)
Definition: combine-nnet.cc:28