4.2. Example 2: Customized Multilayer Perceptron (MLP) Model
This example adds layers to a simple Multilayer Perceptron (MLP) model as follows:
- A ReLU layer was added after each linear transformation in the previous layer.
- A Softmax layer was added at the end.
These additions are shown as an example only. The performance of this customized model has not been tested or optimized.
Model Information:
- Model: Multilayer Perception (MLP)
- Framework: PyTorch®/ONNX*
Figure 3. Original MLP Model Layers
Figure 4. Modified MLP Model Layers
This model is created with the PyTorch® framework but must be converted to ONNX* to use the model with the OpenVINO™ Model Optimizer. The following Python code example illustrates how you can convert the PyTorch® model to ONNX*:
For more information about converting PyTorch® to ONNX*, review the ONNX exporter documentation at the following URL:
https://pytorch.org/docs/stable/onnx.html#example-alexnet-from-pytorch-to-onnx
After the conversion is complete and the ONNX* model is saved, convert the model to OpenVINO™ IR with the following command: