我使用他人制作的健身房环境,可以在 gym-gomoku 当我使用基线尝试训练模型时,会发生错误,例如:
ValueError: Shapes must be equal rank, but are 1 and 2 for 'deepq/Select'
(op: 'Select') with input shapes: [?], [?], [?,361].
我认为环境存在问题,但我无法理解。因为当我在Gym网站上测试其他游戏环境(例如“ CartPole-v0”)时,它成功了。
非常感谢!
这是我的代码:
import gym
from baselines import deepq
def callback(lcl, _glb):
# stop training if reward exceeds 199
is_solved = lcl['t'] > 0.9 and sum(lcl['episode_rewards'][-101:-1]) / 100 >= 0.9
return is_solved
def main():
env = gym.make("Gomoku19x19-v0")
model = deepq.models.mlp([32, 16], layer_norm=True)
act = deepq.learn(
env,
q_func=model,
lr=0.01,
max_timesteps=10000,
print_freq=1,
checkpoint_freq=1000
)
print("Saving model to Gomoku9x9.pkl")
act.save("Gomoku9x9.pkl")
print('Finish!')
if __name__ == '__main__':
main()