【发布时间】:2021-09-09 06:47:38
【问题描述】:
我正在尝试使用来自 Kaggle 上 tensorflow hub 的模型。 像这样:
m = tf.keras.Sequential([
hub.KerasLayer("https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4", output_shape=[1280],
trainable=False), # Can be True, see below.
tf.keras.layers.Dense(num_classes, activation='softmax')
])
m.build([None, 224, 224, 3]) # Batch input shape.
它适用于 GPU,但一旦我切换到带有 TF 记录的 TPU,我就会收到以下错误:
InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on /tmp/tfhub_modules/87fb99f72aec02d017e12c0a3d86c5c182ec22ca/variables/variables: Unimplemented: File system scheme '[local]' not implemented (file: '/tmp/tfhub_modules/87fb99f72aec02d017e12c0a3d86c5c182ec22ca/variables/variables')
但是,设置和 tfrecords 数据集都是正确的,因为它可以将预训练模型切换到相同模型的 keras 应用程序(例如,上面使用 mobilenet keras 应用程序)。
我尝试了缓存,但没有成功,在遵循本指南时我需要注意什么: https://www.tensorflow.org/hub/caching
提前致谢!
【问题讨论】:
标签: tensorflow keras tpu