question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] AttributeError: 'NoneType' object has no attribute 'reset'

See original GitHub issue
import 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:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
Miffylicommented, Aug 27, 2020

Model does not contain an environment, you need to provide one yourself. See docs on load.

1reaction
borninfreedomcommented, Aug 27, 2020

Loading a model without an environment, this model cannot be trained until it has a valid environment. It should be this sentence?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I get AttributeError: 'NoneType' object has no attribute ...
NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None .
Read more >
GeoPandas clip returns AttributeError: 'NoneType' object has ...
When I use geopandas.clip(myline, mypoly) I get AttributeError: 'NoneType' object has no attribute 'intersection'.
Read more >
"AttributeError: 'NoneType' object has no attribute 'group ...
That's a python error. Something went wrong with the version of youtube-dl you're using. I've never used it, so I can't tell you...
Read more >
AttributeError: 'NoneType' object has no attribute 'call' on ...
Hello, I'm at a loss to explain why this flow fails and succeeds at the same time… It only consists in triggering a...
Read more >
'NoneType' Object has no Attribute 'modules' Attri...
Does anyone have experience with this issue while developing a Python script for a script tool? Thanks,. Paul.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found