FailedPreconditionError:在读取张量流预训练模型时读取资源变量模块时出错。

时间:2019-06-19 14:22:49

标签: python tensorflow keras

我已经通过inception3训练了一个二进制图像分类器。创建模型后,我可以立即评估模型。但是,如果我保存模型并重新加载它,然后尝试评估或预测,那么我将收到以下错误:

FailedPreconditionError: Error while reading resource variable module_16/InceptionV3/Mixed_6d/Branch_2/Conv2d_0c_1x7/BatchNorm/beta from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/module_16/InceptionV3/Mixed_6d/Branch_2/Conv2d_0c_1x7/BatchNorm/beta/N10tensorflow3VarE does not exist.
 [[{{node lambda_2_8/module_16_apply_default/InceptionV3/InceptionV3/Mixed_6d/Branch_2/Conv2d_0c_1x7/BatchNorm/ReadVariableOp}}]]

这是代码段:

with tf.compat.v1.Session() as sess:
  sess.run(tf.global_variables_initializer())
  #sess.run(tf.local_variables_initializer())
  new_model = tf.keras.models.load_model('mymodel.h5')
  new_model.summary()
  eval_model=new_model.evaluate(image_test, label_test)
  eval_model

配置: tensorflow 1.14.0-rc1,
Keras 2.2.4-tf

0 个答案:

没有答案