nnet3-am-info.cc
Go to the documentation of this file.
1 // nnet3bin/nnet3-am-info.cc
2 
3 // Copyright 2012-2015 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 #include "base/kaldi-common.h"
21 #include "util/common-utils.h"
22 #include "nnet3/am-nnet-simple.h"
23 #include "hmm/transition-model.h"
24 
25 int main(int argc, char *argv[]) {
26  try {
27  using namespace kaldi;
28  using namespace kaldi::nnet3;
29  typedef kaldi::int32 int32;
30 
31  const char *usage =
32  "Print some text information about an nnet3 neural network, to\n"
33  "standard output\n"
34  "\n"
35  "Usage: nnet3-am-info [options] <nnet>\n"
36  "e.g.:\n"
37  " nnet3-am-info 0.mdl\n"
38  "See also: nnet3-am-info\n";
39 
40  ParseOptions po(usage);
41 
42  po.Read(argc, argv);
43 
44  if (po.NumArgs() != 1) {
45  po.PrintUsage();
46  exit(1);
47  }
48 
49  std::string nnet_rxfilename = po.GetArg(1);
50 
51  TransitionModel trans_model;
52  AmNnetSimple am_nnet;
53  {
54  bool binary;
55  Input ki(nnet_rxfilename, &binary);
56  trans_model.Read(ki.Stream(), binary);
57  am_nnet.Read(ki.Stream(), binary);
58  }
59  std::cout << am_nnet.Info();
60 
61  return 0;
62  } catch(const std::exception &e) {
63  std::cerr << e.what() << '\n';
64  return -1;
65  }
66 }
67 
68 /*
69 Test script:
70 
71 cat <<EOF | nnet3-init --binary=false - - | nnet3-info -
72 component name=affine1 type=NaturalGradientAffineComponent input-dim=72 output-dim=59
73 component name=relu1 type=RectifiedLinearComponent dim=59
74 component name=final_affine type=NaturalGradientAffineComponent input-dim=59 output-dim=298
75 component name=logsoftmax type=SoftmaxComponent dim=298
76 input-node name=input dim=18
77 component-node name=affine1_node component=affine1 input=Append(Offset(input, -4), Offset(input, -3), Offset(input, -2), Offset(input, 0))
78 component-node name=nonlin1 component=relu1 input=affine1_node
79 component-node name=final_affine component=final_affine input=nonlin1
80 component-node name=output_nonlin component=logsoftmax input=final_affine
81 output-node name=output input=output_nonlin
82 EOF
83 */
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
std::string Info() const
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
kaldi::int32 int32
void Read(std::istream &is, bool binary)
std::istream & Stream()
Definition: kaldi-io.cc:826
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void Read(std::istream &is, bool binary)
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
int main(int argc, char *argv[])