Comments (3)
as a quick remark, please use SB3 and the associated RL zoo (cf readme), as SB2 is no longer actively developped.
And please fill the issue template properly.
from rl-baselines-zoo.
I am trying to tune the hyperparameters but the error says :
Trial 2 failed because of the following error: AttributeError("'A2C' object has no attribute 'env'").
However, I have checked with check_env(),it works well with that.
check_env(env, warn=True)
(It works fine)
Output for this:
/usr/local/lib/python3.7/dist-packages/gym/logger.py:30: UserWarning:
WARN: Box bound precision lowered by casting to float32
Instantiate the agent using :
model = A2C('MlpPolicy', env, verbose=1)
And trying to tune the hyperparameter using :
hyperparams={}
data_frame = hyperparam_optimization('a2c', model, model.get_env(), n_trials=100,
n_timesteps=5000, hyperparams=hyperparams,
n_jobs=2, seed=0,
sampler_method='random', pruner_method='median',
verbose=1)
The error is :
[I 2021-05-14 06:39:38,453] Trial 1 finished with value: 800.7374267578125 and parameters: {'gamma': 0.995, 'n_steps': 32, 'lr_schedule': 'constant', 'lr': 0.00026730495810056736, 'ent_coef': 1.0750232421652547e-05, 'vf_coef': 0.3385992446532201}. Best is trial 1 with value: 800.7374267578125.
[W 2021-05-14 06:39:38,469] Trial 2 failed because of the following error: AttributeError("'A2C' object has no attribute 'env'")
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/optuna/_optimize.py", line 217, in run_trial
value_or_values = func(trial)
File "", line 104, in objective
eval_freq = max(eval_freq // model.get_env().num_envs, 1)
File "/usr/local/lib/python3.7/dist-packages/stable_baselines/common/base_class.py", line 104, in get_env
return self.env
AttributeError: 'A2C' object has no attribute 'env'
Just to clarify few things, I used the hyperparam_optimization function(from https://github.com/araffin/rl-baselines-zoo/blob/master/utils/hyperparams_opt.py) with few changes in the objective function.
Line 98 was changed to : model = model_fn #from model = model_fn(**kwargs)
Line 100 was changed to : eval_freq_ = eval_freq #from env_fn(n_envs=1, eval_env=True)
I understand that rl-baselines-zoo can be installed and required command can be run but that too requires the gym registry of the custom-env which was creating issue. I just want to clarify what's wrong in doing this and why the error is 'A2C' object has no attribute 'env' when A2C atually has.
from rl-baselines-zoo.
Just to clarify few things, I used the hyperparam_optimization function(from https://github.com/araffin/rl-baselines-zoo/blob/master/utils/hyperparams_opt.py) with few changes in the objective function.
then please check that the script works without your modification and a normal env. If so, then you know where the issue come from ;)
(we don't do tech support as mentioned explicitly in the issue template and README)
but that too requires the gym registry of the custom-env which was creating issue.
why is that an issue?
https://github.com/DLR-RM/rl-baselines3-zoo#custom-environment
PS: please use markdown to format your code and traceback (cf issue template)
from rl-baselines-zoo.
Related Issues (20)
- HER success_rate output [question]
- What is the best initial values for the parameters in the .yml? [question] HOT 4
- How is the trial value calculated for RL jobs? HOT 1
- update the baseline for new envs? [feature request] HOT 1
- Multithreaded training with SubprocVecEnv() not working HOT 11
- [feature request] Install Zoo as a package HOT 6
- Irreproducible zoo trials HOT 5
- BadZipFile when running PPO2. HOT 5
- Can we use it with Tenserflow 2.3.1 ? HOT 5
- Why during the evaluation VecNormalize stats arenot loaded from the current training stats? HOT 1
- [Question] Why do envs look different? HOT 3
- [Question] Why is ortho_init=False during hyperparameter searches? HOT 2
- [feature request] Hyperparameter optimization for pretrained agent
- SB3 v1.1 Breaking changes HOT 1
- [question] Transfer hyperparameters from optuna HOT 2
- [feature request]Add Mujoco-Gym since mujoco is free now HOT 2
- Missing (or can't find) Hyperparameters HOT 2
- Reproducible zoo result HOT 3
- I am getting ImportError in atari environment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rl-baselines-zoo.