Python tf.keras.estimator.tf.Hub失效的模型对模型估计量
我需要将模型转换为处理B64图像,而不是我使用的JSONPython tf.keras.estimator.tf.Hub失效的模型对模型估计量,python,tensorflow,keras,Python,Tensorflow,Keras,我需要将模型转换为处理B64图像,而不是我使用的JSONtf.keras.estimator.model\u to\u estimator tf-nightly version: Version: 1.15.0-dev20190714 Eager mode: True Hub version: 0.5.0 GPU is available 基于教程 我使用tf.Hub层创建了一个Keras模型: 转换为估计员: estimator = tf.keras.estimator.model
tf.keras.estimator.model\u to\u estimator
tf-nightly version:
Version: 1.15.0-dev20190714
Eager mode: True
Hub version: 0.5.0
GPU is available
基于教程
我使用tf.Hub层创建了一个Keras模型:
转换为估计员:
estimator = tf.keras.estimator.model_to_estimator(
keras_model_path=h5_model_path,
custom_objects={'KerasLayer':hub.KerasLayer},
model_dir=tf_model_path)
我得到:
ValueError: Unknown layer: KerasLayer
FailedPreconditionError: 2 root error(s) found.
(0) Failed precondition: Error while reading resource variable save_counter from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/save_counter/N10tensorflow3VarE does not exist.
[[{{node save_counter/Read/ReadVariableOp}}]]
(1) Failed precondition: Error while reading resource variable save_counter from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/save_counter/N10tensorflow3VarE does not exist.
[[{{node save_counter/Read/ReadVariableOp}}]]
[[MobilenetV2/expanded_conv_15/project/weights/Read/ReadVariableOp/_2363]]
0 successful operations.
0 derived errors ignored.
模型摘要:
model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
keras_layer (KerasLayer) (None, 1280) 2257984
_________________________________________________________________
dense (Dense) (None, 5) 6405
=================================================================
Total params: 2,264,389
Trainable params: 6,405
Non-trainable params: 2,257,984
如果我通过Keras模型对象:
estimator = tf.keras.estimator.model_to_estimator(
keras_model=model,
custom_objects={'KerasLayer':hub.KerasLayer},
model_dir=tf_model_path)
我得到:
ValueError: Unknown layer: KerasLayer
FailedPreconditionError: 2 root error(s) found.
(0) Failed precondition: Error while reading resource variable save_counter from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/save_counter/N10tensorflow3VarE does not exist.
[[{{node save_counter/Read/ReadVariableOp}}]]
(1) Failed precondition: Error while reading resource variable save_counter from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/save_counter/N10tensorflow3VarE does not exist.
[[{{node save_counter/Read/ReadVariableOp}}]]
[[MobilenetV2/expanded_conv_15/project/weights/Read/ReadVariableOp/_2363]]
0 successful operations.
0 derived errors ignored.
嘿,你找到解决方案了吗?这是一个bug,将在本月修复。你找到解决方案了吗?这是一个bug,将在本月修复