Python 如何加载和运行TensorFlow模型
超级简单的问题 我将遵循本教程: 我已经按照说明(不是可选部分)训练了一个模型,并使用tf.saved\u model.save保存了它 现在,我想运行一个新的图片模型。我该怎么做 我尝试了以下方法:Python 如何加载和运行TensorFlow模型,python,tensorflow,keras,Python,Tensorflow,Keras,超级简单的问题 我将遵循本教程: 我已经按照说明(不是可选部分)训练了一个模型,并使用tf.saved\u model.save保存了它 现在,我想运行一个新的图片模型。我该怎么做 我尝试了以下方法: loaded = tf.saved_model.load("/tmp/saved_flowers_model") print(list(loaded.signatures.keys())) # ["serving_default"] infer = loaded.signatures["se
loaded = tf.saved_model.load("/tmp/saved_flowers_model")
print(list(loaded.signatures.keys())) # ["serving_default"]
infer = loaded.signatures["serving_default"]
print(infer.structured_outputs)
file = .../pic.jpg
output = loaded (file)
返回了以下错误:
ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (3 total):
* /Users/dansafdie/Documents/Code Repos/Image Classifier/flower_photos/daisy/19834392829_7d697871f6.jpg
* False
* None
Keyword arguments: {}
Expected these arguments to match one of the following 4 option(s):
Option 1:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='inputs')
* True
* None
Keyword arguments: {}
Option 2:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='inputs')
* False
* None
Keyword arguments: {}
Option 3:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input_1')
* False
* None
Keyword arguments: {}
Option 4:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input_1')
* True
* None
Keyword arguments: {}