“AttributeError:‘dict’对象没有‘flatten’属性”。
运行以下代码时出现此错误:
import math
from gym import Env
from gym.spaces import Discrete, Box, Dict, Tuple, MultiBinary, MultiDiscrete
from stable_baselines3 import PPO
screen_width = 900
class GameEnv(Env):
def __init__(self):
self.action_space = Discrete(5)
observation_positions = Box(low=0, high=screen_width, shape=(2,))
self.observation_space = Dict({'observation_positions': observation_positions})
self.state = self.observation_space.sample()
def step(self, action):
self.state = self.observation_space.sample()
def render(self):
pass
def reset(self):
return self.state
env = GameEnv()
model = PPO('MlpPolicy', env, verbose=1,)
model.learn(total_timesteps=1000)
我必须改变什么?