gonganDV 2020-11-18 20:42 采纳率: 0%
浏览 66

Python inputs incompatible with input_signature:

ValueError: Python inputs incompatible with input_signature:
inputs: (
Tensor("ExpandDims_2:0", shape=(1, 1), dtype=int64),
Tensor("cnn__encoder/StatefulPartitionedCall:0", shape=(1, 64, 256), dtype=float32),
Tensor("rnn__decoder/StatefulPartitionedCall:1", shape=(1, 512), dtype=float32))
input_signature: (
TensorSpec(shape=(1, 1), dtype=tf.int32, name=None),
TensorSpec(shape=(1, 64, 256), dtype=tf.float32, name=None),
TensorSpec(shape=(1, 512), dtype=tf.float32, name=None))

Github issue 链接:https://github.com/tensorflow/tensorflow/issues/42319

https://github.com/tensorflow/tensorflow/issues/44512

在tensorflow提问题都三个月了没人理????试了各种方法都不行。难道TFLiteConvert不能转换带有@tf.function(input_signature=[])的tf.kearas.Model的类?

  • 写回答

2条回答 默认 最新

  • 你知我知皆知 2024-07-24 21:14
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    这个问题是由于TensorFlow模型在转换为TF Lite时,如果它包含了一个input_signature属性,则在转换过程中可能会引发错误。

    解决此问题的方法是确保你的模型没有input_signature属性,并且将其转换为一个简单的inputs列表。这可以通过将input_signature设置为空或删除来实现:

    # 将输入签名设为空
    model = model.__dict__["model"]
    del model.input_signature
    
    # 或者使用空列表
    model = model.__dict__["model"]
    model.input_signature = []
    

    然后你可以尝试运行以下代码以测试是否已经解决了问题:

    print(model)
    

    如果你仍然遇到问题,请提供更详细的错误信息,以便我们能更好地帮助你解决问题。

    评论

报告相同问题?