Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python FailedPremissionError:读取资源变量模块时出错。。在评价张量流预训练模型时_Python_Tensorflow_Keras - Fatal编程技术网

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

Python FailedPremissionError:读取资源变量模块时出错。。在评价张量流预训练模型时,python,tensorflow,keras,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 me

我通过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

你能解决这个问题吗?这个解决方案只是一个黑客。我发现错误只出现在初始模型中,我改为mobilenet,它消失了。之后我在mobilenet进行了完整的培训和测试。