I have a problem with building SNPE neural network corresponding to my DLC file.
I took existing PB model file, which worked fine in an application using TensorFlow interface.
public class TensorFlowClassifier { static { System.loadLibrary("tensorflow_inference"); } private TensorFlowInferenceInterface inferenceInterface; private static final String MODEL_FILE = "file:///android_asset/frozen_model.pb"; private static final String INPUT_NODE = "inputs"; private static final String[] OUTPUT_NODES = {"y_"}; private static final String OUTPUT_NODE = "y_"; private static final long[] INPUT_SIZE = {1, 200, 3}; private static final int OUTPUT_SIZE = 6; public TensorFlowClassifier(final Context context) { inferenceInterface = new TensorFlowInferenceInterface(context.getAssets(), MODEL_FILE); } public float[] processData(float[] data) { float[] result = new float[OUTPUT_SIZE]; inferenceInterface.feed(INPUT_NODE, data, INPUT_SIZE); inferenceInterface.run(OUTPUT_NODES); inferenceInterface.fetch(OUTPUT_NODE, result); return result; } }
I converted the PB model to DLC by means of the following command:
./snpe-1.17.1/bin/x86_64-linux-clang/snpe-tensorflow-to-dlc --graph ~/ALPHA/FrozenModelLSTM/frozen_har.pb -i "input" 1,200,3 --out_node "y_" --dlc frozen_har.dlc --allow_unconsumed_nodes
I used the created DLC model file in my application:
final SNPE.NeuralNetworkBuilder builder = new SNPE.NeuralNetworkBuilder(mApp) .setDebugEnabled(false) // Allows selecting a runtime order for the network. .setRuntimeOrder(CPU) // Loads a model from DLC file .setModel(new File(modelFileWithPath)); Log.e(LOG_TAG, "Before builder.build()"); network = builder.build();
However builder.build() command fails with exception:
"Unable to create network! Cause: error_code=403; error_message=No output is defined. Network has empty outputs; error_component=Dl Network; line_no=302; thread_id=548102384280"
It is so strange that TensorFlow interface succeeds to read output layer in PB file, however the SNPE SDK does not see the same layer.
Please help. Will be very grateful for your prompt answer.
Hi Svetlana,
Could you try adding '.setOutputLayers("y_")' to your list of builder options? I'm not sure why the builder couldn't determine this automatically, hopefully telling it the name explicitly will help.
Regards,
David