我有两个文件,learn.py保存模型,learn_2.py恢复模型(这里是tf.variable a)并初始化新的tf.variable b,但是出了问题,这里是错误的:
tensorflow.python.framework.errors_impl.NotFoundError: Key scope/bb not found in checkpoint
learn.py
import tensorflow as tf
with tf.variable_scope("scope"):
a = tf.get_variable("aa", shape=[2
在Tensorflow 1.12上,我试图编辑一个变量,但是即使在运行赋值操作之后,更新的值也不会被保存。
import tensorflow as tf
tf.reset_default_graph()
g = tf.Graph()
with g.as_default(), tf.Session(graph=g) as sess:
w = tf.Variable(2,name = "VARIABLE")
sess.run(tf.global_variables_initializer())
y = sess.run(w)
print(
考虑到以下代码:
import tensorflow as tf
with tf.Session() as sess:
var = tf.Variable(42, name='var')
sess.run(tf.global_variables_initializer())
tf.train.export_meta_graph('file.meta')
with tf.Session() as sess:
saver = tf.train.import_meta_graph('file.meta')
p
我观察到一种奇怪的行为,如果检查点早些时候保存在相同的Python进程中,则Saver无法恢复。如果从不同的过程中完成,它就会装载得很好。以下是一些简单的代码,将显示问题。
import tensorflow.compat.v1 as tf
def train():
W = tf.Variable(tf.zeros([1, 1]))
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
saver.
我使用卷积自动编码器神经网络方法训练模型并将其保存,但是当我恢复模型重建与训练图像相似的图像时,重建结果很差,损失很大。我不确定我是否在保存和读取文件时出错。
训练模型并保存它!
#--------------------------------------------------------------------------
x = tf.placeholder(tf.float32, [None, dim], name = "X")
y = tf.placeholder(tf.float32, [None, dim], name = "Y")
keeppr
我是tensorflow的新手,当我尝试从保存的变量中恢复保存的参数时,我得到了"NotFoundError: Key b_1 not in检查点“,完整的代码位于下面。谢谢你的帮助!
import tensorflow as tf
import numpy as np
## save to a file
## need to use the same shape and dtype when restore
W = tf.Variable([[1,2,3],[3,4,5]], dtype=tf.float32, name='W')
b = tf.Variable([[
我在一个会话中将变量恢复到图形中,关闭该会话,然后创建一个新会话,在该会话中我尝试评估该图形。这样做的时候,我得到了错误FailedPreconditionError: Attempting to use uninitialized value ...。
尝试在第一个会话中评估该图效果良好。
在第二个会话中调用sess.run(tf.global_variables_initializer())可以“修复”这个问题,但是它会重置变量的值。
初始恢复使用以下命令完成:
meta_graph_def = meta_graph.read_meta_graph_file(meta_graph_file