问题描述
看到了一段这样的代码:
ac_space = env.action_space
actdim = ac_space.shape[0]
结果出现报错:Atrribute error: 'Discrete' object has no attribute 'shape',说ac_space是Discrete(5) object,没有shape参数,于是去找了一下如何获取当前环境的动作空间大小和状态空间大小。
解决方案
action_size = env.action_space.n
state_size = env.observation_space.n
参考链接
python - How to user "Discrete" object in openai-gym environments? - Stack Overflow