FailedPreconditionError:从容器读取资源变量dense_95/kernel时出错:本地主机

问题描述

我提前定义了一个 VAEloss 函数。当我调用这个函数并得到一个阈值时,我发现它是一个张量变量。当我尝试使用以下命令查看此 Tensor 时,系统报告错误。有谁知道如何解决它? 错误信息如下:

`def vae_loss(x,x_decoded_mean):
  xent_loss=original_dim*objectives.binary_crossentropy(x,x_decoded_mean)
  kl_loss=-0.5*K.sum(1+z_log_var-K.square(z_mean)-K.exp(z_log_var),axis=-1)
  return xent_loss+kl_loss
vae=Model(x,x_decoded_mean)
vae.compile(optimizer='rmsprop',loss=vae_loss,experimental_run_tf_function = False)
vae.summary()`
`thereshold=vae_loss(data_train,train_x_pred)
thereshold_mean=tf.reduce_mean(thereshold)
t_max=tf.argmax(thereshold,0)
with tf.Session() as sess:
print(sess.run(t_max))`

FailedPreconditionError:从容器读取资源变量密集_95/内核时出错:本地主机。这可能意味着该变量未初始化。未找到:容器 localhost 不存在。 (找不到资源:localhost/dense_95/kernel) [[{{节点密集_95/MatMul/ReadVariableOp}}]]

在处理上述异常的过程中,又发生了一个异常:

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)