Converting a Kaldi* Model

Note

The Model Optimizer supports the nnet1 and nnet2 formats of Kaldi models. Support of the nnet3 format is limited.

Convert a Kaldi* Model

To convert a Kaldi* model, run Model Optimizer with the path to the input model .nnet or .mdl file:

mo --input_model <INPUT_MODEL>.nnet

Using Kaldi*-Specific Conversion Parameters

The following list provides the Kaldi*-specific parameters.

Kaldi-specific parameters:
  --counts COUNTS       A file name with full path to the counts file or empty string to utilize count values from the model file
  --remove_output_softmax
                        Removes the Softmax that is the output layer
  --remove_memory       Remove the Memory layer and add new inputs and outputs instead

Examples of CLI Commands

  • To launch the Model Optimizer for the wsj_dnn5b_smbr model with the specified .nnet file:

    mo --input_model wsj_dnn5b_smbr.nnet
  • To launch the Model Optimizer for the wsj_dnn5b_smbr model with existing file that contains counts for the last layer with biases:

    mo --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts
    • The Model Optimizer normalizes сounts in the following way:

      \[S = \frac{1}{\sum_{j = 0}^{|C|}C_{j}}\]
      \[C_{i}=log(S\*C_{i})\]

      where \(C\) - the counts array, \(C_{i} - i^{th}\) element of the counts array, \(|C|\) - number of elements in the counts array;

    • The normalized counts are subtracted from biases of the last or next to last layer (if last layer is SoftMax).

Note

Model Optimizer will show warning if model contains counts values inside model and --counts option is not used.

  • If you want to remove the last SoftMax layer in the topology, launch the Model Optimizer with the --remove_output_softmax flag:

    mo --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts --remove_output_softmax

The Model Optimizer finds the last layer of the topology and removes this layer only if it is a SoftMax layer.

Note

Model Optimizer can remove SoftMax layer only if the topology has one output.

Note

For sample inference of Kaldi models, you can use the OpenVINO Speech Recognition sample application. The sample supports models with one output. If your model has several outputs, specify the desired one with the --output option.

If you want to convert a model for inference on Intel® Movidius™ Myriad™, use the --remove_memory option. It removes Memory layers from the IR. Instead of it, additional inputs and outputs appear in the IR. The Model Optimizer outputs the mapping between inputs and outputs. For example:

[ WARNING ]  Add input/output mapped Parameter_0_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out -> Result_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out
[ WARNING ]  Add input/output mapped Parameter_1_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out -> Result_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out
[ WARNING ]  Add input/output mapped Parameter_0_for_iteration_Offset_fastlstm3.c_trunc__3390 -> Result_for_iteration_Offset_fastlstm3.c_trunc__3390

Based on this mapping, link inputs and outputs in your application manually as follows:

  1. Initialize inputs from the mapping as zeros in the first frame of an utterance.

  2. Copy output blobs from the mapping to the corresponding inputs. For example, data from Result_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out must be copied to Parameter_0_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out.

Supported Kaldi* Layers

Refer to Supported Framework Layers for the list of supported standard layers.