Giter VIP home page Giter VIP logo

reinforcementlearningcourse's People

Contributors

nicknochnack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

reinforcementlearningcourse's Issues

Self Driving Car: .7z files won't work properly on the model

Unless I'm missing something on the tutorial, .7z files for the self-driving car won't work. I get the following Erro message:

Traceback (most recent call last):
  File "/Users/vagman/Desktop/uni-classes/self-driving-car/car.py", line 38, in <module>
    model = PPO.load(ppo_path, env)
  File "/opt/homebrew/lib/python3.9/site-packages/stable_baselines3/common/base_class.py", line 709, in load
    if "policy_kwargs" in data:
TypeError: argument of type 'NoneType' is not iterable
# 1. Import libraries
import os
import gym
from stable_baselines3 import PPO
from stable_baselines3.common.vec_env.dummy_vec_env import DummyVecEnv
from stable_baselines3.common.evaluation import evaluate_policy

# 2. Test Environment
environment_name = "CarRacing-v0"
env = gym.make(environment_name)
episodes = 1

for episode in range(1, episodes+1):
    state = env.reset()
    done = False
    score = 0 
    
    while not done:
        env.render()
        action = env.action_space.sample()
        n_state, reward, done, info = env.step(action)
        score+=reward
    print('Episode: {} - Score:{}'.format(episode, str(score)[:6]))
env.close()

# 3. Train Model
print("Training our model..")
env = gym.make(environment_name)
env = DummyVecEnv([lambda: env])
log_path = os.path.join('Training', 'Logs')
model = PPO("CnnPolicy", env, verbose = 1, tensorboard_log = log_path)
model.learn(total_timesteps = 2000000)

# 4. Save/Load Model
print("Saving the model to a file..")
ppo_path = os.path.join('Training', 'Saved Models', 'PPO_2m_Driving_model_2')
model = PPO.load(ppo_path, env)

# 5 Evaluate and Test
print("Evaluating our model..")
evaluate_policy(model, env, n_eval_episodes = 10, render = True)

I tried to convert the .7z training file into .zip. The program will run normally but the car won't move at all when I add PPO_2m_Driving_model_2.zip in load(). The car will keep losing points and it will restart the map once again repeating the same process.
Any ideas ?

Got AssertionError while loading trained autonomous driving models.

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.