tensorflow Fehlermeldung: ValueError: Could not find matching function to call loaded from the SavedModel

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
webster1309
User
Beiträge: 1
Registriert: Samstag 24. Juli 2021, 13:52

Hallo,

aus einem Lehrbuch für Transfer Learning habe ich den Code unten 1:1 kopiert und erhalte die Fehlermeldung. Ich vermute, dass IMAGE_SHAPE die falschen Dimensionen hat, aber ich habe schon alle möglichen Kombinationen und eigentlich müsste die erzeugte (224, 224,3) Shape auch stimmen. Was in der Fehlermeldung unter Optionen steht, kann ich nicht ganz nachvollziehen. Vielleicht hat jemand eine Idee.

Code:

import tensorflow as tf
import tensorflow_hub as hub
import numpy as np i
mport matplotlib.pyplot as plt

module_url = "https://tfhub.dev/google/imagenet/mobil ... e_vector/4"
my_model = hub.KerasLayer(module_url)
classifier_url = "https://tfhub.dev/google/imagenet/mobil ... e_vector/4"
IMAGE_SHAPE = (224,224)
classifier = tf.keras.Sequential([hub.KerasLayer(classifier_url, input_shape = IMAGE_SHAPE+(3,))])

Errormessage:
graph_function = self._create_graph_function(args, kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py:3289 _create_graph_function
capture_by_value=self._capture_by_value),
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py:999 func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py:672 wrapped_fn
out = weak_wrapped_fn().__wrapped__(*args, **kwds)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/saved_model/function_deserialization.py:291 restored_function_body
"\n\n".join(signature_descriptions)))

ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (4 total):
* Tensor("inputs:0", shape=(None, 224, 224, 3), dtype=float32)
* False
* False
* 0.99
Keyword arguments: {}

Expected these arguments to match one of the following 4 option(s):

Option 1:
Positional arguments (4 total):
* TensorSpec(shape=(None, 160, 160, 3), dtype=tf.float32, name='inputs')
* False
* False
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}

Option 2:
Positional arguments (4 total):
* TensorSpec(shape=(None, 160, 160, 3), dtype=tf.float32, name='inputs')
* False
* True
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}

Option 3:
Positional arguments (4 total):
* TensorSpec(shape=(None, 160, 160, 3), dtype=tf.float32, name='inputs')
* True
* True
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}

Option 4:
Positional arguments (4 total):
* TensorSpec(shape=(None, 160, 160, 3), dtype=tf.float32, name='inputs')
* True
* False
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}
Antworten