A summary of the steps for optimizing and deploying a model that was trained with Kaldi*:
-
Configure the Model Optimizer for Kaldi*.
-
Convert a Kaldi* Model to produce an optimized Intermediate Representation (IR) of the model based on the trained network topology, weights, and biases values.
- Test the model in the Intermediate Representation format using the Inference Engine in the target environment via provided Inference Engine validation application or sample applications.
-
Integrate the Inference Engine in your application to deploy the model in the target environment.
NOTE: The Model Optimizer supports only nnet1 and nnet2 format of Kaldi models. Note that nnet3 format is not supported.
Supported Topologies
- Convolutional Neural Networks (CNN):
- Wall Street Journal CNN (wsj_cnn4b)
- Resource Management CNN (rm_cnn4a_smbr)
- Long Short Term Memory (LSTM) Networks:
- Resource Management LSTM (rm_lstm4f)
- TED-LIUM LSTM (ted_lstm4f)
- Deep Neural Networks (DNN):
- Wall Street Journal DNN (wsj_dnn5b_smbr);
- TED-LIUM DNN (ted_dnn_smbr)
Convert a Kaldi* Model
To convert a Kaldi* model:
- Go to the
<INSTALL_DIR>/deployment_tools/model_optimizer
directory.
- Use the
mo.py
script to simply convert a model with the path to the input model .nnet
file: python3 mo.py --input_model <INPUT_MODEL>.nnet
Two groups of parameters are available to convert your model:
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
--remove_output_softmax
Removes the Softmax layer that is the output layer
Examples of CLI Commands
- To launch the Model Optimizer for the wsj_dnn5b_smbr model with the specified
.nnet
file: python3 mo.py --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:
python3 mo.py --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts
- If you want to remove the last SoftMax layer in the topology, launch the Model Optimizer with the
--remove_output_softmax
flag. python3 mo.py --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.
Supported Kaldi* Layers
Refer to Supported Framework Layers for the list of supported standard layers.