Generate an optimized 32-bit model
This step primarily removes unnecessary nodes and ensures that the operations that are used are available in the TensorFlow distributions on mobile devices. One way it does this is by removing training-specific operations in the model's computational graph.
To generate your model, enter the following on the command line:
bazel-bin/tensorflow/tools/graph_transforms/transform_graph \ --in_graph=resnetv1_50_fp32.pb \ --out_graph=optimized_resnetv1_50_fp32.pb \ --inputs='Placeholder' \ --outputs='resnet_v1_50/predictions/Reshape_1' \ --transforms='strip_unused_nodes(type=float, shape="1,224,224,3") fold_constants(ignore_errors=true) fold_batch_norms fold_old_batch_norms'
The input and output names will depend on your model. The shape is also included here as part of the strip_unused_nodes command.
If you encounter any problems, the TensorFlow documentation covers this step in more detail.
The transformed model will not differ greatly in size or speed from the training model. The difference is that it is capable of being loaded by the TensorFlow distribution for mobile devices, which may not implement all training operators.
It is a good idea to verify that this inference-ready model runs with the same accuracy as your trained one. How you do this will depend on your training/test workflow and datasets.
You can now distribute this model and deploy it with TensorFlow on both mobile and embedded or low-power Linux devices.
|Node names||8-bit model|