Tensorflow Output nodes replaced with StatefulPartitionedCall which is throwing ValueError on load

Viewed 934

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)?

0 Answers
Related