vita-epfl / CrowdNav

[ICRA19] Crowd-aware Robot Navigation with Attention-based Deep Reinforcement Learning
MIT License
585 stars 169 forks source link

Problem in changing the optimizer #51

Open westbrook123 opened 2 years ago

westbrook123 commented 2 years ago

I tried different optimizer during the training period: SGD and Adam. However, after I modified trainer.py as: self.optimizer = optim.Adam(self.model.parameters(), lr=learning_rate) and run python train.py --policy sarl in terminal, it appears:

Traceback (most recent call last): File "train.py", line 177, in main() File "train.py", line 159, in main explorer.run_k_episodes(env.case_size['val'], 'val', episode=episode) File "/home/jackeywang/CrowdNav/crowd_nav/utils/explorer.py", line 42, in run_k_episodes action = self.robot.act(ob) File "/home/jackeywang/CrowdNav/crowd_sim/envs/utils/robot.py", line 13, in act action = self.policy.predict(state) File "/home/jackeywang/CrowdNav/crowd_nav/policy/multi_human_rl.py", line 58, in predict raise ValueError('Value network is not well trained. ') ValueError: Value network is not well trained.

I can't figure out why different optimizer can cause error like that, hope for your help.

ChanganVR commented 2 years ago

@westbrook123 did you print the values of the action? Looks like the network might have produced NaN, which led to no action being chosen.

I don't know why just changing the optimizer makes such a difference, but in my experience, at least in this repo, SGD works better than Adam.

westbrook123 commented 2 years ago

@westbrook123 did you print the values of the action? Looks like the network might have produced NaN, which led to no action being chosen.

I don't know why just changing the optimizer makes such a difference, but in my experience, at least in this repo, SGD works better than Adam.

Thanks for your reply, I won't modify the optimizer any more. By the way, I have also read your work RGL, may I ask how the heatmap in your paper is drawn? Thank you so much!

ChanganVR commented 2 years ago

The code for plotting the heatmap is here: https://github.com/ChanganVR/RelationalGraphLearning/blob/8e87aa5ed8221efd688f8e6857ba4c38637bf6e1/crowd_sim/envs/crowd_sim.py#L591-L615

westbrook123 commented 2 years ago

The code for plotting the heatmap is here: https://github.com/ChanganVR/RelationalGraphLearning/blob/8e87aa5ed8221efd688f8e6857ba4c38637bf6e1/crowd_sim/envs/crowd_sim.py#L591-L615

Thankyou so much, I'll try it.