[question] AttributeError: 'NoneType' object has no attribute 'reset'
See original GitHub issueimport gym
from stable_baselines import DQN,PPO2
from stable_baselines.common.evaluation import evaluate_policy
env=gym.make('LunarLander-v2')
model=DQN('MlpPolicy',env,learning_rate=1e-3,prioritized_replay=True,verbose=1)
model.learn(total_timesteps=int(2e5))
model.save('dqn_lunar')
del model
model=DQN.load('dqn_lunar')
mean_reward,std_reward=evaluate_policy(model,model.get_env(),n_eval_episodes=10)
obs=env.reset()
for i in range(1000):
action,_state=model.predict(obs)
obs,rewards,dones,info=env.step(action)
env.render()
Describe the bug Traceback (most recent call last): File “”, line 1, in <module> File “C:\Program Files\JetBrains\PyCharm 2020.2\plugins\python\helpers\pydev_pydev_bundle\pydev_umd.py”, line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File “C:\Program Files\JetBrains\PyCharm 2020.2\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py”, line 18, in execfile exec(compile(contents+“\n”, file, ‘exec’), glob, loc) File “C:/Users/born_/PycharmProjects/test_sb/main.py”, line 41, in <module> mean_reward,std_reward=evaluate_policy(model,model.get_env(),n_eval_episodes=10) File “C:\Users\born_\anaconda3\envs\workEnv\lib\site-packages\stable_baselines\common\evaluation.py”, line 49, in evaluate_policy obs = env.reset() AttributeError: ‘NoneType’ object has no attribute ‘reset’
System Info
- anaconda3
- NVIDIA RTX 2080
- Python 3.6
- tensorflow-gpu==1.15.0
- cuda 10.0, cudnn 7.6.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top GitHub Comments
Model does not contain an environment, you need to provide one yourself. See docs on
load
.Loading a model without an environment, this model cannot be trained until it has a valid environment.
It should be this sentence?