Edit Caffe model for inference
To start running inference on a Caffe inference model using IBM Spectrum Conductor Deep Learning Impact, an inference.prototxt file is required. The inference.prototxt file cannot include a training data layer or include any layers that are dependent on data labels.
Typically, to create an inference.prototxt file, you can modify the
training network file as follows:
- Remove the data layer that was used for training, as for in the case of classification we are no
longer providing labels for our data. For example, change the following model,
from:
To:layer { name: "cifar" type: "MemoryData" top: "data" top: "label" ... } layer { name: "cifar" type: "MemoryData" top: "data" top: "label" include { phase: TEST } ... }layer { name: "data" type: "Input" top: "data" # input shape must be the same as in train network input_param { shape: { dim: 128 dim: 3 dim: 32 dim: 32 } } } - Remove any layer that is dependent upon data labels.
- Set the network up to accept and output data. For example, change the following model, from:
To:layer { name: "accuracy" type: "Accuracy" bottom: "ip1" bottom: "label" top: "accuracy" } layer { name: "loss" type: "SoftmaxWithLoss" bottom: "ip1" bottom: "label" top: "loss" }layer { name: "prob" type: "Softmax" bottom: "ip1" top: "prob" }