我正在使用带有tensorflow 1.14的教程Hub with Keras。我没有为MacOS does not seem to be available点安装tf-nightly-gpu。一切都顺利,直到keras.Sequential()为止:
import tensorflow_hub as hub
from tensorflow.keras import layers
classifier_url ="https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3"
IMAGE_SHAPE = (224, 224)
classifier = tf.keras.Sequential([
hub.KerasLayer(classifier_url, input_shape=IMAGE_SHAPE+(3,))
])
最后一行给出以下错误:
ValueError: Importing a SavedModel with tf.saved_model.load requires a 'tags=' argument if there is more than one MetaGraph. Got 'tags=None', but there are 2 MetaGraphs in the SavedModel with tag sets [[], ['train']]. Pass a 'tags=' argument to load this SavedModel.
它与tensorflow版本有关还是与其他东西有关?
MacOS High Sierra 10.13.1 python 3.6.8 tensorflow 1.14.0
答案 0 :(得分:3)
这在TF 1.14.0中对我有用:
# Image information
HEIGHT = 224
WIDTH = 224
CHANNELS = 3
IMAGE_SHAPE = (HEIGHT, WIDTH)
feature_extractor_url = "https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3" #@param {type:"string"}
module = hub.Module(feature_extractor_url, tags=['train'])
feature_extractor_layer = hub.KerasLayer(module,
input_shape=(HEIGHT, WIDTH, CHANNELS))