26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
34 "Copy a (cpu-based) neural net: reads the AmNnet with its transition model, but\n" 35 "writes just the Nnet with no transition model (i.e. the raw neural net.)\n" 37 "Usage: nnet-to-raw-nnet [options] <nnet-in> <raw-nnet-out>\n" 39 " nnet-to-raw-nnet --binary=false 1.mdl 1.raw\n";
42 bool binary_write =
true;
45 po.
Register(
"binary", &binary_write,
"Write output in binary mode");
46 po.
Register(
"truncate", &truncate,
"If set, will truncate the neural net " 47 "to this many components by removing the last components.");
56 std::string nnet_rxfilename = po.
GetArg(1),
57 raw_nnet_wxfilename = po.
GetArg(2);
63 Input ki(nnet_rxfilename, &binary);
69 KALDI_LOG <<
"Truncating neural net to " << truncate <<
" layers.";
76 KALDI_LOG <<
"Read neural net from " << nnet_rxfilename
77 <<
" and wrote raw neural net to " << raw_nnet_wxfilename;
79 }
catch(
const std::exception &e) {
80 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Read(std::istream &is, bool binary)
void Resize(int32 num_components)
Removes final components from the neural network (used for debugging).
void Register(const std::string &name, bool *ptr, const std::string &doc)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
int main(int argc, char *argv[])
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).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
const Nnet & GetNnet() const