hill-a / stable-baselines

A fork of OpenAI Baselines, implementations of reinforcement learning algorithms
http://stable-baselines.readthedocs.io/
MIT License
4.16k stars 725 forks source link

(Question) Change the value of a default variable of the env using make_vec_env #1051

Closed Chaivara closed 3 years ago

Chaivara commented 3 years ago

(Question) I'm using make_vec_env to create parallel workers. I want to change a variable value from default one. Tried 2 approaches

  1. env.configure() throws errors.
  2. I dont know how to use Kwargs in make_vec_env() There should be a better way of doing this. Any help would be appreciated.

Code example

import highway_env
from stable_baselines.common import make_vec_env

env = make_vec_env('highway-v0')
env.envs[0].env.configure({"observation": {"type": "Kinematics","vehicles_count": 15}})
env.envs[0].env.reset()
env.reset()

System Info Describe the characteristic of your environment:

Traceback (most recent call last):
  File "W:/CMV/pythonProject-gpu/New.py", line 46, in <module>
    env.reset()
  File "W:\CMV\anaconda3\envs\tf-gpu\lib\site-packages\stable_baselines\common\vec_env\dummy_vec_env.py", line 62, in reset
    self._save_obs(env_idx, obs)
  File "W:\CMV\anaconda3\envs\tf-gpu\lib\site-packages\stable_baselines\common\vec_env\dummy_vec_env.py", line 92, in _save_obs
    self.buf_obs[key][env_idx] = obs
ValueError: could not broadcast input array from shape (15,5) into shape (5,5)
araffin commented 3 years ago

Probably a duplicate of https://github.com/hill-a/stable-baselines/issues/1032 and you should take a look at env_method() method (cf doc).