当我尝试用tensorflow重新训练模型时,它显示了一个错误:
**error module 'tensorflow_hub' has no attribute 'KerasLayer'**代码是:
print("Building model with", MODULE_HANDLE)
model = tf.keras.Sequential([
hub.KerasLayer(MODULE_HANDLE, output_shape=[FV_SIZE],
trainable=do_fine_tuning),
tf.keras.layers.Dropout(rate=0.2),
tf.keras.layers.Dense(train_generator.num_classes,
activation='softmax',
kernel_regularizer=tf.keras.regularizers.l2(0.0001))
])
model.build((None,)+IMAGE_SIZE+(3,))
model.summary()错误如下:
1 print("Building model with", MODULE_HANDLE)
2 model = tf.keras.Sequential([
----> 3 hub.KerasLayer(MODULE_HANDLE, output_shape=[FV_SIZE],
4 trainable=do_fine_tuning),
5 tf.keras.layers.Dropout(rate=0.2),
AttributeError: module 'tensorflow_hub' has no attribute 'KerasLayer'通过使用tensorflow集线器重新训练以前的集线器模型,通过添加新的完全连接的layers.when运行代码,它显示了上述error.is任何关于that.please帮助的想法
发布于 2019-04-23 22:33:21
请检查tensorflow版本。它应该是最新的夜间版本。
当我使用像1.13.1这样的版本时,我在错误前看到以下警告,没有属性'KerasLayer':
W0423 20:04:16.453974 139707130586880 __init__.py:56] Some hub symbols are not available because TensorFlow version is less than 1.14在执行pip install "tf-nightly"之后,一切都很正常。
https://www.tensorflow.org/hub
对于BatchNormalizationv1问题,您可以每晚使用tf2.0,它也可以处理原始问题。
pip install -U tf-nightly-2.0-previewhttps://stackoverflow.com/questions/55804154
复制相似问题