7

I am applying transfer learning on the ssd_mobilenet_v2_coco_2018_03_29 model. After the training, I am using tf.saved_model.save(model, saved_model_dir) to save the keras model as saved_model.pb.

The original ssd_mobilenet_v2_coco_2018_03_29 model has the following signature defs.

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['inputs'] tensor_info:
        dtype: DT_UINT8
        shape: (-1, -1, -1, 3)
        name: image_tensor:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['detection_boxes'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 100, 4)
        name: detection_boxes:0
    outputs['detection_classes'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 100)
        name: detection_classes:0
    outputs['detection_scores'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 100)
        name: detection_scores:0
    outputs['num_detections'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: num_detections:0
  Method name is: tensorflow/serving/predict

The saved model has the following signature defs (defaults).

  signature_def['__saved_model_init_op']:
  The given SavedModel SignatureDef contains the following input(s):
  The given SavedModel SignatureDef contains the following output(s):
    outputs['__saved_model_init_op'] tensor_info:
        dtype: DT_INVALID
        shape: unknown_rank
        name: NoOp
  Method name is:

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['mobilenetv2_1.00_224_input'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 224, 224, 3)
        name: serving_default_mobilenetv2_1.00_224_input:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['dense'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 5)
        name: StatefulPartitionedCall:0
  Method name is: tensorflow/serving/predict

The original model has 4 output nodes detection_boxes, detection_classes, detection_scores, num_detections. How is it getting StatefulPartitionedCall when I'm exporting it as a saved model? I viewed the saved model using tensorboard and all the 4 output nodes are visible.

[tensorboard image]: [1]: https://i.stack.imgur.com/abbqI.png

When I'm trying to load the (frozen) saved model using batchnorm, I'm getting the following error ValueError: Input 1 of node prefix/StatefulPartitionedCall was passed float from prefix/Conv1/kernel:0 incompatible with expected resource.

Any idea what's going on? How can I restore the original output nodes (which is still visible)?

user3433050
  • 93
  • 1
  • 6
  • 1
    I have multi output model (three outputs) developed in tf.keras and facing the same issue where all the output names are changed to StatefulPartitionedCall:0, StatefulPartitionedCall:1, StatefulPartitionedCall:2 – Arvind Mar 03 '21 at 15:25
  • how did you fix it? – omer Aug 08 '21 at 15:20
  • I'm encountering a problem with StatefulPartitionedCall and have established it seems to be introduced by nested @tf.function calls, in case that helps your reasoning on this problem at all. – kylejmcintyre Apr 01 '22 at 22:28
  • refer to https://stackoverflow.com/questions/59142040/tensorflow-2-0-how-to-change-the-output-signature-while-using-tf-saved-model and to https://stackoverflow.com/questions/55738456/losing-output-node-names-in-tensorflow-model-after-fine-tuning-from-pre-trained?rq=1 – YScharf Apr 13 '22 at 11:43

0 Answers0