【发布时间】:2019-08-07 21:06:51
【问题描述】:
我正在关注使用 tensorflow 1.14 的教程 Hub with Keras。我没有为 MacOS 安装 tf-nightly-gpu,因为它 does not seem to be available。在 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 蟒蛇 3.6.8 张量流 1.14.0
【问题讨论】:
-
我被困在同一个
module = hub.load(feature_extractor_url, tags='train') print(type(module)) #feature_extractor_layer = hub.KerasLayer(module, # input_shape=(HEIGHT, WIDTH, CHANNELS))返回错误,看起来句柄可能在 TF 2.X 中工作,将检查。 -
“将 TF2 的 Hub 模块(或类似的可调用)包装为 Keras 层。” tensorflow.org/hub/api_docs/python/hub/KerasLayer
标签: python-3.x tensorflow