AN 993: Using Custom Models with Intel® FPGA AI Suite

ID 777190
Date 5/01/2023
Public

4.1. Example 1: Customized ResNet-18 Model

This example removes the last Fully Connected (FC) layer to test if a performance difference exists. The ResNet-18 model is supported by Intel® FPGA AI Suite, but removing the last layer has not been tested. This example does not show how to test the modified model.

The removal is shown as an example only. The performance of this customized model has not been tested or optimized.

Model information:
  • Model: ResNet-18
  • Framework: Caffe
Figure 2. ResNet-18 Fully Connected (FC) Layer
layer { bottom: "pool5" top: "fc1000" name: "fc1000" type: "InnerProduct" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 1 } inner_product_param { num_output: 1000 weight_filler { type: "xavier" } bias_filler { type: "constant" value: 0 } } } layer { bottom: "fc1000" name: "prob" type: "Softmax" top: "prob" }

This code example shows that the Fully Connected layer was removed from the model. This removal is done by deleting the lines of code from the PROTOTXT (.prototxt) file.

The modified PROTOTXT file is then used to generate the OpenVINO™ intermediate representation (IR) form of the model. To generate the IR for the modified model, run the following command:
mo_caffe.py --input_model <path to model>.caffemodel --input_proto <path to .prototxt>

This command runs the OpenVINO™ Model Optimizer and creates three files that are the IR of this customized model: deploy.xml, deploy.mapping, and deploy.bin.