DLR-RM / rl-baselines3-zoo

A training framework for Stable Baselines3 reinforcement learning agents, with hyperparameter optimization and pre-trained agents included.
https://rl-baselines3-zoo.readthedocs.io
MIT License
1.9k stars 495 forks source link

error due to model and env observation space mismatch when I load pretrained agent #369

Closed chang2727 closed 1 year ago

chang2727 commented 1 year ago

❓ Question

Hi, when I continue training,that is load pretrained agent for my own environment, I found the observation space in the saved model is not correspond with the definition! What's the problem? I'm confused.

Loading saved VecNormalize stats Loading pretrained agent Traceback (most recent call last): File "/home/sc/rl-baseline3-zoo/train.py", line 237, in results = exp_manager.setup_experiment() File "/home/sc/rl-baseline3-zoo/utils/exp_manager.py", line 188, in setup_experiment model = self._load_pretrained_agent(self._hyperparams, env) File "/home/sc/rl-baseline3-zoo/utils/exp_manager.py", line 607, in _load_pretrained_agent model = ALGOS[self.algo].load( File "/home/sc/miniconda3/envs/sc_mujoco2.3/lib/python3.10/site-packages/stable_baselines3/common/base_class.py", line 684, in load check_for_correct_spaces(env, data["observation_space"], data["action_space"]) File "/home/sc/miniconda3/envs/sc_mujoco2.3/lib/python3.10/site-packages/stable_baselines3/common/utils.py", line 228, in check_for_correct_spaces raise ValueError(f"Observation spaces do not match: {observation_space} != {env.observation_space}") ValueError: Observation spaces do not match: Dict(achieved_goal: Box(-inf, inf, (3,), float64), desired_goal: Box(-inf, inf, (3,), float64), observation: Box(-inf, inf, (14,), float64), rope_in_hand: Box(0.0, 1.0, (1, 1), float32), touch_info_0: Box(-10.0, 10.0, (3, 32, 32), float32), touch_info_1: Box(-10.0, 10.0, (3, 32, 32), float32)) != Dict(achieved_goal: Box(-inf, inf, (3,), float64), desired_goal: Box(-inf, inf, (3,), float64), observation: Box(-inf, inf, (14,), float64), rope_in_hand: Box(0.0, 1.0, (1, 1), float32), touch_info_0: Box(0, 255, (3, 32, 32), uint8), touch_info_1: Box(0, 255, (3, 32, 32), uint8))

Checklist

qgallouedec commented 1 year ago

Hi, we need more information to answer you. I suggest you to use the bug report template instead. Unless you are using a custom env, then use the custom env template.

cidxb commented 1 year ago

I have encounter this kind of problem, have you change your env script after you trained this agint ?

Changing the observation space or action space dimension can potentially lead to this problem.

chang2727 commented 1 year ago

I have encounter this kind of problem, have you change your env script after you trained this agint ?

Changing the observation space or action space dimension can potentially lead to this problem.

I didn't change the script. But I found that changing the stable_baselines3 version from 1.7.0 to 1.6.0 can solve the problem