2017-10-29 108 views
0

我想用Q学习训练CatPole-V0喂养tensorflow占位符。当试图更新用丰富的经验,我收到以下错误重传缓冲器:从一个数组

ValueError: Cannot feed value of shape (128,) for Tensor 'Placeholder_1:0', which has shape '(?, 2)' 

相关的代码片段是:

def update_replay_buffer(replay_buffer, state, action, reward, next_state, done, action_dim): 
    # append to buffer 
    experience = (state, action, reward, next_state, done) 
    replay_buffer.append(experience) 
    # Ensure replay_buffer doesn't grow larger than REPLAY_SIZE 
    if len(replay_buffer) > REPLAY_SIZE: 
     replay_buffer.pop(0) 
    return None 

占位待供应

action_in = tf.placeholder("float", [None, action_dim]) 

灿有人澄清应该如何使用action_dim来解决这个错误?

回答

0

首先让我们来action_in

action_in = tf.placeholder("float", [None, action_dim]) 

这意味着action_in可以有外形似(None, action_dim),没有什么比这其他。从错误中:

ValueError: Cannot feed value of shape (128,) for Tensor 'Placeholder_1:0', which has shape '(?, 2)' 

从错误似乎您action_dim2。 很容易看出,你把形状(128,)的目标到位的张其预计外形似(?, 2)(None, 2)

所以你需要检查你feed_dict这就是你搞乱。您的占位符action_in的尺寸应与你在feed_dict投入对象。

Can someone clarify how action_dim should be used to resolve this error?

看来你的环境的行动已经从action_dim价值两个部分组成,但你只提供one成分,这是从你的错误((128,))推断。你需要解决这个问题。希望这可以帮助。