从此文件:https://github.com/llSourcell/pong_neural_network_live/blob/master/RL.py
我已更新了这些行
#first convolutional layer. bias vector
#creates an empty tensor with all elements set to zero with a shape
W_conv1 = tf.Variable(tf.zeros([8, 8, 4, 32]) , name='W_conv1')
b_conv1 = tf.Variable(tf.zeros([32]), name='b_conv1')
W_conv2 = tf.Variable(tf.zeros([4, 4, 32, 64]), name='W_conv2')
b_conv2 = tf.Variable(tf.zeros([64]), name='b_conv2')
W_conv3 = tf.Variable(tf.zeros([3, 3, 64, 64]), name='W_conv3')
b_conv3 = tf.Variable(tf.zeros([64]), name='b_conv3')
W_fc4 = tf.Variable(tf.zeros([3136, 784]), name='W_fc4')
b_fc4 = tf.Variable(tf.zeros([784]), name='b_fc4')
W_fc5 = tf.Variable(tf.zeros([784, ACTIONS]), name='W_fc5')
b_fc5 = tf.Variable(tf.zeros([ACTIONS]), name='b_fc5')
和
saver.save(sess, './' + 'pong' + '-dqn', global_step = timestamp)
并在:
def main():
# ////
tf.reset_default_graph()
imported_meta = tf.train.import_meta_graph('./' + 'pong' + '-dqn-' + '48000' + '.meta')
imported_meta.restore(sess, tf.train.latest_checkpoint('./'))
# ////
尝试恢复模型但出现此错误:
TypeError:无法将feed_dict键解释为Tensor:名称“save / Const:0”指的是不存在的Tensor。图中不存在“save / Const”操作。
当我尝试这个时:
graph = tf.get_default_graph()
W_conv1 = graph.get_tensor_by_name("W_conv1:0")
b_conv1 = graph.get_tensor_by_name("wb_conv1:0")
W_conv2 = graph.get_tensor_by_name("W_conv2:0")
b_conv2 = graph.get_tensor_by_name("wb_conv2:0")
W_conv3 = graph.get_tensor_by_name("W_conv3:0")
b_conv3 = graph.get_tensor_by_name("b_conv3:0")
W_fc4 = graph.get_tensor_by_name("W_fc4:0")
b_fc4 = graph.get_tensor_by_name("b_fc4:0")
W_fc5 = graph.get_tensor_by_name("W_fc5:0")
b_fc5 = graph.get_tensor_by_name("b_fc5:0")
我收到此错误:
“名称'W_conv1:0'指的是不存在的Tensor。图中不存在'W_conv1'操作。
为什么会这样? 我在pygame中创建了我的游戏,我正在尝试将它连接到RL。 我想确保我可以保存并加载我的进度。我只是遇到了如何保存和加载的逻辑问题。
提前致谢!