Skip to content

Got AssertionError while loading trained autonomous driving models. #3

Description

What I did in Jupyter Notebook:

import os
import gym
from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import DummyVecEnv
from stable_baselines3.common.evaluation import evaluate_policy
environment_name = "CarRacing-v0"
env = gym.make(environment_name)
env = DummyVecEnv([lambda: env])
ppo_path = os.path.join("Training", "Saved Models", "PPO_428k_Driving_model")
model = PPO.load(ppo_path, env)

When I run the last section, I got this AssertionError:

Wrapping the env in a VecTransposeImage.
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
d:\GitHub\autonomous-driving\ad_notebook.ipynb Cell 14 in <cell line: 2>()
      [1](vscode-notebook-cell:/d%3A/GitHub/autonomous-driving/ad_notebook.ipynb#X16sZmlsZQ%3D%3D?line=0) # model.save(ppo_path)
----> [2](vscode-notebook-cell:/d%3A/GitHub/autonomous-driving/ad_notebook.ipynb#X16sZmlsZQ%3D%3D?line=1) model = PPO.load(ppo_path, env)

File c:\Users\user\anaconda3\envs\RLstation\lib\site-packages\stable_baselines3\common\base_class.py:747, in BaseAlgorithm.load(cls, path, env, device, custom_objects, print_system_info, force_reset, **kwargs)
    745 model.__dict__.update(data)
    746 model.__dict__.update(kwargs)
--> 747 model._setup_model()
    749 # put state_dicts back in place
    750 model.set_parameters(params, exact_match=True, device=device)

File c:\Users\user\anaconda3\envs\RLstation\lib\site-packages\stable_baselines3\ppo\ppo.py:168, in PPO._setup_model(self)
    165 super()._setup_model()
    167 # Initialize schedules for policy/value clipping
--> 168 self.clip_range = get_schedule_fn(self.clip_range)
    169 if self.clip_range_vf is not None:
    170     if isinstance(self.clip_range_vf, (float, int)):

File c:\Users\user\anaconda3\envs\RLstation\lib\site-packages\stable_baselines3\common\utils.py:91, in get_schedule_fn(value_schedule)
     89     value_schedule = constant_fn(float(value_schedule))
     90 else:
---> 91     assert callable(value_schedule)
     92 return value_schedule

AssertionError:

So, I trained a model with $428000$ timesteps. And loaded that. That model worked perfectly. I cannot understand what is the reason of this error occurring. I also downloaded the PPO_2m_Driving_model.zip and also got the same AssertionError. Do anyone know what is the problem?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions