Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行时发现的bug #1

Open
ShuaiLi-XY opened this issue May 20, 2023 · 3 comments
Open

运行时发现的bug #1

ShuaiLi-XY opened this issue May 20, 2023 · 3 comments

Comments

@ShuaiLi-XY
Copy link

============================= test session starts ============================= platform win32 -- Python 3.9.12, pytest-7.1.1, pluggy-1.0.0 -- D:\anaconda\python.exe cachedir: .pytest_cache rootdir: E:\python_project\snake-ai-other\main plugins: anyio-3.5.0 collecting ... test_cnn.py:None (test_cnn.py) test_cnn.py:25: in <module> model = MaskablePPO.load(MODEL_PATH) D:\anaconda\lib\site-packages\stable_baselines3\common\base_class.py:687: in load raise KeyError("The observation_space and action_space were not given, can't verify new environments") E KeyError: "The observation_space and action_space were not given, can't verify new environments" collected 0 items / 1 error
报错点:D:\anaconda\lib\site-packages\stable_baselines3\common\base_class.py:687
断点调试发现 observation_space were not given。这是什么意思,萌新菜鸟求教。

@Sakura-Shino
Copy link

Sakura-Shino commented May 20, 2023

可参考 #linyiLYi/street-fighter-ai#16

image

keys = ['high', 'low', 'bounded_above', 'bounded_below']
setattr(env.observation_space, '_shape', (3,84,84))
for k in keys:
    new_attr = getattr(env.observation_space, k).reshape(3,84,84)
    setattr(env.observation_space, k, new_attr)

# Load the trained model
model = MaskablePPO.load(MODEL_PATH,env=env,custom_objects={'observation_space': env.observation_space, 'action_space': env.action_space})

@aijunzhao
Copy link

可参考 #linyiLYi/street-fighter-ai#16

image

keys = ['high', 'low', 'bounded_above', 'bounded_below']
setattr(env.observation_space, '_shape', (3,84,84))
for k in keys:
    new_attr = getattr(env.observation_space, k).reshape(3,84,84)
    setattr(env.observation_space, k, new_attr)

# Load the trained model
model = MaskablePPO.load(MODEL_PATH,env=env,custom_objects={'observation_space': env.observation_space, 'action_space': env.action_space})

知道怎么改board大小吗,12*12感觉有点小,改成24,就报错了,也是这个ValueError: Error: Unexpected observation shape (72, 72, 3) for Box environment, please use (3, 84, 84) or (n_env, 3, 84, 84) for the observation shape.

@linyiLYi
Copy link
Owner

linyiLYi commented Jun 1, 2023

如果改了 board 大小,模型输入部分也要改一下,在 snake_game_custom_wrapper 里面

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants