nnet3-info.cc
Go to the documentation of this file.
1 // nnet3bin/nnet3-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/nnet-nnet.h"
23 
24 int main(int argc, char *argv[]) {
25  try {
26  using namespace kaldi;
27  using namespace kaldi::nnet3;
28  typedef kaldi::int32 int32;
29 
30  const char *usage =
31  "Print some text information about 'raw' nnet3 neural network, to\n"
32  "standard output\n"
33  "\n"
34  "Usage: nnet3-info [options] <raw-nnet>\n"
35  "e.g.:\n"
36  " nnet3-info 0.raw\n"
37  "See also: nnet3-am-info\n";
38 
39  ParseOptions po(usage);
40 
41  po.Read(argc, argv);
42 
43  if (po.NumArgs() != 1) {
44  po.PrintUsage();
45  exit(1);
46  }
47 
48  std::string raw_nnet_rxfilename = po.GetArg(1);
49 
50  Nnet nnet;
51  ReadKaldiObject(raw_nnet_rxfilename, &nnet);
52 
53  std::cout << nnet.Info();
54 
55  return 0;
56  } catch(const std::exception &e) {
57  std::cerr << e.what() << '\n';
58  return -1;
59  }
60 }
61 
62 /*
63 Test script:
64 
65 cat <<EOF | nnet3-init --binary=false - - | nnet3-info -
66 component name=affine1 type=NaturalGradientAffineComponent input-dim=72 output-dim=59
67 component name=relu1 type=RectifiedLinearComponent dim=59
68 component name=final_affine type=NaturalGradientAffineComponent input-dim=59 output-dim=298
69 component name=logsoftmax type=SoftmaxComponent dim=298
70 input-node name=input dim=18
71 component-node name=affine1_node component=affine1 input=Append(Offset(input, -4), Offset(input, -3), Offset(input, -2), Offset(input, 0))
72 component-node name=nonlin1 component=relu1 input=affine1_node
73 component-node name=final_affine component=final_affine input=nonlin1
74 component-node name=output_nonlin component=logsoftmax input=final_affine
75 output-node name=output input=output_nonlin
76 EOF
77 */
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
kaldi::int32 int32
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:832
std::string Info() const
returns some human-readable information about the network, mostly for debugging purposes.
Definition: nnet-nnet.cc:821
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
int main(int argc, char *argv[])
Definition: nnet3-info.cc:24
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).