`import setup_path
import gym
import airgym
import time
from stable_baselines3 import DQN
from stable_baselines3.common.monitor import Monitor
from stable_baselines3.common.vec_env import DummyVecEnv, VecTransposeImage
from stable_baselines3.common.evaluation import evaluate_policy
from stable_baselines3.common.callbacks import EvalCallback
'# Create a DummyVecEnv for main airsim gym env'
env = DummyVecEnv(
[
lambda: Monitor(
gym.make(
"airgym:airsim-drone-sample-v0",
ip_address="127.0.0.1",
step_length = 0.1,
image_shape=(84, 84, 1),
)
)
]
)
env = VecTransposeImage(env)
'# Train the agent => works and create .zip file'
model.learn(
total_timesteps=1e5,
tb_log_name="dqn_airsim_dronerun" + str(time.time()),
**kwargs
)
'# Load the trained agent => TypeError'
model = DQN.load("dqn_airsim_drone_policy", env = env)
my full error is
'
Exception ignored in: <function AirSimDroneEnv.del at 0x000001E8977C3D38>
Traceback (most recent call last):
File "c:\Users\user\source\repos\AirSim\PythonClient\reinforcement_learning\airgym\envs\drone_env.py", line 57, in del
File "c:\Users\user\source\repos\AirSim\PythonClient\airsim\client.py", line 26, in reset
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\session.py", line 41, in call
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\future.py", line 25, in get
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\future.py", line 22, in join
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\loop.py", line 22, in start
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\ioloop.py", line 711, in start
TypeError: 'NoneType' object is not callable
'
System Info
GPU models and configuration = CPU i5, GPU RTX 2080 Ti
Hello. I'm using Stable-baseline3 for Reinforcement Learning in Airsim environment. My gym and stable-baseline3 code works well when I do learning.
But, it creates error = TypeError: 'NoneType' object is not callable
when I load the network to evalulate the network that I trained.
Phenomenon are describe below; 1. Training works fine, and successful to create .zip file that contatins network information
2. But when load model.load standalone, then it gets error "model = DQN.load("dqn_airsim_drone_policy", env = env)"
3. Interesting thing is that when I use evaluate_policy function, then it iterates for n_eval_episodes that set, then get same error on 2.
"model = DQN.load("dqn_airsim_drone_policy", env = env) mean_reward, std_reward = evaluate_policy(model, model.get_env(), n_eval_episodes=10)"
Before begin first here's my code:
`import setup_path import gym import airgym import time
from stable_baselines3 import DQN from stable_baselines3.common.monitor import Monitor from stable_baselines3.common.vec_env import DummyVecEnv, VecTransposeImage from stable_baselines3.common.evaluation import evaluate_policy from stable_baselines3.common.callbacks import EvalCallback
'# Create a DummyVecEnv for main airsim gym env' env = DummyVecEnv( [ lambda: Monitor( gym.make( "airgym:airsim-drone-sample-v0", ip_address="127.0.0.1", step_length = 0.1, image_shape=(84, 84, 1), ) ) ] )
env = VecTransposeImage(env)
'# Train the agent => works and create .zip file' model.learn( total_timesteps=1e5, tb_log_name="dqn_airsim_dronerun" + str(time.time()), **kwargs )
'# Load the trained agent => TypeError' model = DQN.load("dqn_airsim_drone_policy", env = env)
'# evaluate policy => Type Error' mean_reward, std_reward = evaluate_policy(model, model.get_env(), n_eval_episodes=10)
my full error is ' Exception ignored in: <function AirSimDroneEnv.del at 0x000001E8977C3D38> Traceback (most recent call last): File "c:\Users\user\source\repos\AirSim\PythonClient\reinforcement_learning\airgym\envs\drone_env.py", line 57, in del File "c:\Users\user\source\repos\AirSim\PythonClient\airsim\client.py", line 26, in reset File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\session.py", line 41, in call File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\future.py", line 25, in get File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\future.py", line 22, in join File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\msgpackrpc\loop.py", line 22, in start File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\ioloop.py", line 711, in start TypeError: 'NoneType' object is not callable '
System Info
Thank you in advanced, Best