nnet-info.cc
Go to the documentation of this file.
1 // nnetbin/nnet-info.cc
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 #include "base/kaldi-common.h"
21 #include "util/common-utils.h"
22 #include "nnet/nnet-nnet.h"
23 
24 int main(int argc, char *argv[]) {
25  try {
26  using namespace kaldi;
27  using namespace kaldi::nnet1;
28  typedef kaldi::int32 int32;
29 
30  const char *usage =
31  "Print human-readable information about the neural network.\n"
32  "(topology, various weight statistics, etc.) It prints to stdout.\n"
33  "Usage: nnet-info [options] <nnet-in>\n"
34  "e.g.:\n"
35  " nnet-info 1.nnet\n";
36 
37  ParseOptions po(usage);
38  po.Read(argc, argv);
39 
40  if (po.NumArgs() != 1) {
41  po.PrintUsage();
42  exit(1);
43  }
44 
45  std::string nnet_rxfilename = po.GetArg(1);
46 
47  // load the network
48  Nnet nnet;
49  {
50  bool binary_read;
51  Input ki(nnet_rxfilename, &binary_read);
52  nnet.Read(ki.Stream(), binary_read);
53  }
54 
55  std::cout << nnet.Info();
56 
57  KALDI_LOG << "Printed info about " << nnet_rxfilename;
58  return 0;
59  } catch(const std::exception &e) {
60  std::cerr << e.what();
61  return -1;
62  }
63 }
64 
65 
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
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
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
void Read(const std::string &rxfilename)
Read Nnet from &#39;rxfilename&#39;,.
Definition: nnet-nnet.cc:333
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).
std::string Info() const
Create string with human readable description of the nnet,.
Definition: nnet-nnet.cc:386
#define KALDI_LOG
Definition: kaldi-error.h:153
int main(int argc, char *argv[])
Definition: nnet-info.cc:24