所以我试着用Tensorflow建立我的第一个Q学习神经网络。我的PolicyStep和TimeStep是由Tensorflow、policy.action和env.step生成的,但是它们还有一个额外的维度。但是agent.train需要一个时间步骤和操作步骤的扁平版本。我不知道为什么会发生这种情况,因为在我的代理和轨迹收集函数中使用了相同的环境。
loss = agent.train(experience=traj).loss
ValueError: All of the Tensors in `value` must have two outer dimensions. Specifically, tensors must have shape `[B, T] + spec.shape`.
Full shapes of value tensors:
Trajectory(
{'action': TensorShape([1]),
'discount': TensorShape([1]),
'next_step_type': TensorShape([1]),
'observation': TensorShape([1, 54]),
'policy_info': (),
'reward': TensorShape([1]),
'step_type': TensorShape([1])}).
Expected shapes (excluding the two outer dimensions):
Trajectory(
{'action': TensorShape([]),
'discount': TensorShape([]),
'next_step_type': TensorShape([]),
'observation': TensorShape([54]),
'policy_info': (),
'reward': TensorShape([]),
'step_type': TensorShape([])}).我如何使我的轨道信息变平,这样额外的维度就消失了?
发布于 2022-02-27 04:26:38
通过切换到混响,而不是手动实现collect_step方法,使其工作。
https://stackoverflow.com/questions/71261921
复制相似问题