34 const bool use_preconditioned_affine_component) {
41 if (use_preconditioned_affine_component) {
85 std::vector<int32> frame_offsets;
87 std::ostringstream ostr;
90 std::istringstream istr(ostr.str());
131 const bool use_preconditioned_affine_component) {
136 use_preconditioned_affine_component);
149 default:
KALDI_ERR <<
"Un-handled nnet1 component type " 157 const bool use_preconditioned_affine_component) {
160 std::vector<nnet2::Component*> *components =
new std::vector<nnet2::Component*>();
161 components->resize(size);
162 for (
size_t i = 0;
i < size;
i++) {
164 use_preconditioned_affine_component);
168 res->Init(components);
176 int main(
int argc,
char *argv[]) {
178 using namespace kaldi;
182 "Convert nnet1 neural net to nnet2 'raw' neural net\n" 184 "Usage: nnet1-to-raw-nnet [options] <nnet1-in> <nnet2-out>\n" 186 " nnet1-to-raw-nnet srcdir/final.nnet - | nnet-am-init dest/tree dest/topo - dest/0.mdl\n";
188 bool binary_write =
true, use_preconditioned_affine_component =
false;
189 int32 srand_seed = 0;
192 po.
Register(
"binary", &binary_write,
"Write output in binary mode");
194 po.
Register(
"use_preconditioned_affine_component",
195 &use_preconditioned_affine_component,
196 "Using AffineComponentPreconditionOnline instead AffineComponent");
206 std::string nnet1_rxfilename = po.
GetArg(1),
207 raw_nnet2_wxfilename = po.
GetArg(2);
212 use_preconditioned_affine_component);
214 KALDI_LOG <<
"Converted nnet1 neural net to raw nnet2 and wrote it to " 218 }
catch(
const std::exception &e) {
219 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
nnet2::Component * ConvertSoftmaxComponent(const nnet1::Component &nnet1_component)
void Init(const CuVectorBase< BaseFloat > &scales)
int32 NumComponents() const
Returns the number of 'Components' which form the NN.
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
Abstract class, basic element of the network, it is a box with defined inputs, outputs, and tranformation functions interface.
void Init(int32 input_dim, std::vector< int32 > context, int32 const_component_dim=0)
void GetParams(VectorBase< BaseFloat > *params) const
Get the trainable parameters reshaped as a vector,.
int32 NumParams() const
Number of trainable parameters,.
ComponentType
Component type identification mechanism,.
Rescale the data column-wise by a vector (can be used for global variance normalization) ...
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
nnet2::Component * ConvertSpliceComponent(const nnet1::Component &nnet1_component)
FixedScaleComponent applies a fixed per-element scale; it's similar to the Rescale component in the n...
static const char * TypeToMarker(ComponentType t)
Converts component type to marker,.
nnet2::Component * ConvertRescaleComponent(const nnet1::Component &nnet1_component)
Adds shift to all the lines of the matrix (can be used for global mean normalization) ...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void ReadIntegerVector(std::istream &is, bool binary, std::vector< T > *v)
Function for reading STL vector of integer types.
Splices the time context of the input features in N, out k*N, FrameOffset o_1,o_2,...,o_k FrameOffset example 11frames: -5 -4 -3 -2 -1 0 1 2 3 4 5.
int32 InputDim() const
Get the dimension of the input,.
void WriteData(std::ostream &os, bool binary) const
Writes the component content.
nnet2::Nnet * ConvertNnet1ToNnet2(const nnet1::Nnet &nnet1, const bool use_preconditioned_affine_component)
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
nnet2::Component * ConvertAddShiftComponent(const nnet1::Component &nnet1_component)
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
FixedBiasComponent applies a fixed per-element bias; it's similar to the AddShift component in the nn...
int NumArgs() const
Number of positional parameters (c.f. argc-1).
nnet2::Component * ConvertAffineTransformComponent(const nnet1::Component &nnet1_component, const bool use_preconditioned_affine_component)
void GetParams(VectorBase< BaseFloat > *params) const
Get the trainable parameters reshaped as a vector,.
A class representing a vector.
#define KALDI_ASSERT(cond)
Keywords: natural gradient descent, NG-SGD, naturalgradient.
const Component & GetComponent(int32 c) const
Component accessor,.
virtual ComponentType GetType() const =0
Get Type Identification of the component,.
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
std::string PrintableWxfilename(const std::string &wxfilename)
PrintableWxfilename turns the wxfilename into a more human-readable form for error reporting...
Abstract class, building block of the network.
void Init(const CuVectorBase< BaseFloat > &scales)
int main(int argc, char *argv[])
Splices a context window of frames together [over time].
nnet2::Component * ConvertSigmoidComponent(const nnet1::Component &nnet1_component)
int32 NumParams() const
Number of trainable parameters,.
nnet2::Component * ConvertComponent(const nnet1::Component &nnet1_component, const bool use_preconditioned_affine_component)