I trained a simple model with Keras/TF2.5 and saved it as saved model.
tf.saved_model.save(my_model,'/path/to/model')
If I examine it via
saved_model_cli show --dir /path/to/model --tag_set serve --signature_def serving_default
I get these outputs/names:
inputs['conv2d_input'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 32, 32, 1)
name: serving_default_conv2d_input:0
outputs['dense'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 2)
name: StatefulPartitionedCall:0
The names serving_default_conv2d_input
and StatefulPartitionedCall
can actually be used for inference.
I want to extract them using python API. If I query it by loading the model:
>>> m=tf.saved_model.load('/path/to/model')
>>> m.signatures['serving_default'].inputs[0].name
'conv2d_input:0'
>>> m.signatures['serving_default'].outputs[0].name
'Identity:0'
I get entirely different names.
Questions:
- How can I extract these names
serving_default_conv2d_input
andStatefulPartitionedCall
from python API? - Alternatively how can I define/fix the names when I call
tf.saved_model.save
? - What does
:0
mean?
And side question:
How do you handle deployment TF model to production via SavedModel?