eleurent / rl-agents

Implementations of Reinforcement Learning and Planning algorithms
MIT License
578 stars 150 forks source link

Hi ! #34

Closed CFXgoon closed 4 years ago

CFXgoon commented 4 years ago

Hello!I have a problem in the ego_attention.json,The problem is when use the ego_attention.json to train the agent in the env_obs_attention, the error is happend: [ERROR] Preferred device cuda:best unavailable, switching to default cpu INFO: Creating monitor directory out/HighwayEnv/DQNAgent/run_20200408-221242_4475 Traceback (most recent call last): File "experiments.py", line 148, in main() File "experiments.py", line 43, in main evaluate(opts[''], opts[''], opts) File "experiments.py", line 75, in evaluate display_rewards=not options['--no-display']) File "/home/cfxgg/rl-agents-master/rl_agents/trainer/evaluation.py", line 82, in init self.agent.set_writer(self.writer) File "/home/cfxgg/rl-agents-master/rl_agents/agents/deep_q_network/pytorch.py", line 98, in set_writer dtype=torch.float, device=self.device)) File "/home/cfxgg/conda/envs/test/lib/python3.7/site-packages/tensorboardX/writer.py", line 804, in add_graph self._get_file_writer().add_graph(graph(model, input_to_model, verbose, profile_with_cuda, kwargs)) File "/home/cfxgg/conda/envs/test/lib/python3.7/site-packages/tensorboardX/pytorch_graph.py", line 344, in graph result = model(args) File "/home/cfxgg/conda/envs/test/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(input, kwargs) File "/home/cfxgg/rl-agents-master/rl_agents/agents/common/models.py", line 284, in forward ego_embeddedatt, = self.forward_attention(x) File "/home/cfxgg/rl-agents-master/rl_agents/agents/common/models.py", line 296, in forward_attention ego, others, mask = self.split_input(x) File "/home/cfxgg/rl-agents-master/rl_agents/agents/common/models.py", line 289, in split_input ego = x[:, 0:1, :] IndexError: too many indices for tensor of dimension 2 How can I solve the problem ? I look forward to your reply !

CFXgoon commented 4 years ago

@CFXgoon for questions about highway-env, you can add issues on the original repo https://github.com/eleurent/highway-env/issues

The longitudinal and lateral control is achieved here: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L10

The steering_control() method (https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L112) chooses a steering command to track a target_lane, while the velocity_control chooses an acceleration command to reach the desired target_velocity: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L142

Ok, Thanks a lot! ! !

CFXgoon commented 4 years ago

@CFXgoon for questions about highway-env, you can add issues on the original repo https://github.com/eleurent/highway-env/issues

The longitudinal and lateral control is achieved here: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L10

The steering_control() method (https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L112) chooses a steering command to track a target_lane, while the velocity_control chooses an acceleration command to reach the desired target_velocity: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L142

Hi,i find a problem that when i find the metadata.json,the information is: "model": { "advantage": { "layers": [], "out": null, "type": "MultiLayerPerceptron" }, "base_module": { "out": null, "type": "MultiLayerPerceptron" }, "in": 25, "layers": [ 256, 256 ], "out": 5, "type": "DuelingNetwork", "value": { "layers": [], "out": null, "type": "MultiLayerPerceptron" } }, the "out" is null,and the highway environment is not match with the highway_env.py and how can i do next? Thanks!!!

CFXgoon commented 4 years ago

@CFXgoon for questions about highway-env, you can add issues on the original repo https://github.com/eleurent/highway-env/issues The longitudinal and lateral control is achieved here: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L10 The steering_control() method (https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L112) chooses a steering command to track a target_lane, while the velocity_control chooses an acceleration command to reach the desired target_velocity: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L142

Hi,i find a problem that when i find the metadata.json,the information is: "model": { "advantage": { "layers": [], "out": null, "type": "MultiLayerPerceptron" }, "base_module": { "out": null, "type": "MultiLayerPerceptron" }, "in": 25, "layers": [ 256, 256 ], "out": 5, "type": "DuelingNetwork", "value": { "layers": [], "out": null, "type": "MultiLayerPerceptron" } }, the "out" is null,and the highway environment is not match with the highway_env.py and how can i do next? Thanks!!!

@CFXgoon for questions about highway-env, you can add issues on the original repo https://github.com/eleurent/highway-env/issues

The longitudinal and lateral control is achieved here: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L10

The steering_control() method (https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L112) chooses a steering command to track a target_lane, while the velocity_control chooses an acceleration command to reach the desired target_velocity: https://github.com/eleurent/highway-env/blob/master/highway_env/vehicle/controller.py#L142

Hi, i find that the terminal information is this: File "experiments.py", line 148, in main() File "experiments.py", line 43, in main evaluate(opts[''], opts[''], opts) File "experiments.py", line 77, in evaluate evaluation.train() File "/home/cfxgg/.local/lib/python3.7/site-packages/rl_agents/trainer/evaluation.py", line 106, in train self.run_episodes() File "/home/cfxgg/.local/lib/python3.7/site-packages/rl_agents/trainer/evaluation.py", line 131, in run_episodes reward, terminal = self.step() File "/home/cfxgg/.local/lib/python3.7/site-packages/rl_agents/trainer/evaluation.py", line 162, in step self.observation, reward, terminal, info = self.monitor.step(action) File "/home/cfxgg/.local/lib/python3.7/site-packages/gym/wrappers/monitor.py", line 31, in step observation, reward, done, info = self.env.step(action) File "/home/cfxgg/.local/lib/python3.7/site-packages/highway_env/envs/highway_env.py", line 50, in step return super().step(action) File "/home/cfxgg/.local/lib/python3.7/site-packages/highway_env/envs/common/abstract.py", line 177, in step self._simulate(action) File "/home/cfxgg/.local/lib/python3.7/site-packages/highway_env/envs/common/abstract.py", line 211, in _simulate self.road.act() File "/home/cfxgg/.local/lib/python3.7/site-packages/highway_env/road/road.py", line 276, in act vehicle.act() File "/home/cfxgg/.local/lib/python3.7/site-packages/highway_env/vehicle/behavior.py", line 91, in act super().act(action) File "/home/cfxgg.local/lib/python3.7/site-packages/highway_env/vehicle/controller.py", line 97, in act action = {"steering": self.steering_control(self.target_lane_index), File "/home/cfxgg/.local/lib/python3.7/site-packages/highway_env/vehicle/controller.py", line 133, in steering_control heading_ref = lane_future_heading + np.clip(heading_command, -np.pi/4, np.pi/4) File "<__array_function__ internals>", line 6, in clip File "/home/cfxgg/miniconda2/envs/test/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 2084, in clip return _wrapfunc(a, 'clip', a_min, a_max, out=out, *kwargs) File "/home/cfxgg/miniconda2/envs/test/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc return bound(args, **kwds) File "/home/cfxgg/miniconda2/envs/test/lib/python3.7/site-packages/numpy/core/_methods.py", line 106, in _clip if _clip_dep_is_scalar_nan(min): File "/home/cfxgg/miniconda2/envs/test/lib/python3.7/site-packages/numpy/core/_methods.py", line 65, in _clip_dep_is_scalar_nan from numpy.core.fromnumeric import ndim KeyboardInterrupt so the environment path is ""/home/cfxgg/.local/lib/python3.7/",in the past the path is "/home/cfxgg/rl-agents-master/rl_agents/trainer/evaluation.py", and i can't find the path " /home/cfxgg/.local/lib/python3.7", so how can i change the path? Thanks!!!

eleurent commented 4 years ago

So you had two questions:

  1. the metadata.json seems alright to me. Some layer sizes are not specified ("out": null) because they are inherited from the parent module (here, "out: 5). What do you mean by: _highway environment is not match with the highwayenv.py ?
  2. they you have a questions about your python path, but I'm not sure how I can help. I would advise uninstalling highway-env and either cloning it locally or reinstalling it in the proper environment. It seems to be working though, until you stop with a KeyboardInterrupt, isn't it?
eleurent commented 4 years ago

Hi @CFXgoon , After updating pytorch, I could finally reproduce your initial error: IndexError: too many indices for tensor of dimension 2. It seems to be caused by a change of behaviour in recent pytorch versions, and should be fixed now.

CFXgoon commented 4 years ago

Hi @CFXgoon , After updating pytorch, I could finally reproduce your initial error: IndexError: too many indices for tensor of dimension 2. It seems to be caused by a change of behaviour in recent pytorch versions, and should be fixed now.

Thanks a lot !!!