首页 > 解决方案 > 如何更改我的 RL 模型的输出形状?

问题描述

我在 Google Colab 上使用 python 和 kerasrl-2。我正在研究 Gym BipedalWalker-v3 环境。但我得到了这个错误:

--> 385             self.joints[0].motorSpeed     = float(SPEED_HIP     * np.sign(action[0]))
    386             self.joints[0].maxMotorTorque = float(MOTORS_TORQUE * np.clip(np.abs(action[0]), 0, 1))
    387             self.joints[1].motorSpeed     = float(SPEED_KNEE    * np.sign(action[1]))


TypeError: 'int' object is not subscriptable

我认为我的问题的根源是我的输出形状:

Layer (type)                 Output Shape              Param #   
=================================================================
flatten_13 (Flatten)         (None, 24)                0         
_________________________________________________________________
dense_55 (Dense)             (None, 32)                800       
_________________________________________________________________
dense_56 (Dense)             (None, 30)                990       
_________________________________________________________________
dense_57 (Dense)             (None, 24)                744       
_________________________________________________________________
dense_58 (Dense)             (None, 4)                 100    


(None, 4) # This is my output shape   

这是环境的动作信息:

env = gym.make('BipedalWalker-v3')
env.action_space # (Box(-1.0, 1.0, (4,), float32))

env.action_space.sample() # array([-0.07326526,  0.73222667,  0.6016823,  0.4056189, dtype=float32)

env.action_space.shape # (4,)

如果我的想法不对,你能告诉我我哪里错了吗?

标签: pythontensorflowkerasreinforcement-learningopenai-gym

解决方案


推荐阅读