vita-epfl / CrowdNav

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

How to train from RL? () #54

Closed Yuanzizizi closed 2 years ago

Yuanzizizi commented 2 years ago

If I just want to go straight to RL, can I just remove (#) the following code?

imitation learning

# if args.resume:
#     if not os.path.exists(rl_weight_file):
#         logging.error('RL weights does not exist')
#     model.load_state_dict(torch.load(rl_weight_file))
#     rl_weight_file = os.path.join(args.output_dir, 'resumed_rl_model.pth')
#     logging.info('Load reinforcement learning trained weights. Resume training')
# elif os.path.exists(il_weight_file):
#     model.load_state_dict(torch.load(il_weight_file))
#     logging.info('Load imitation learning trained weights.')
# else:
#     il_episodes = train_config.getint('imitation_learning', 'il_episodes')
#     il_policy = train_config.get('imitation_learning', 'il_policy')
#     il_epochs = train_config.getint('imitation_learning', 'il_epochs')
#     il_learning_rate = train_config.getfloat('imitation_learning', 'il_learning_rate')
#     trainer.set_learning_rate(il_learning_rate)
#     if robot.visible:
#         safety_space = 0
#     else:
#         safety_space = train_config.getfloat('imitation_learning', 'safety_space')
#     il_policy = policy_factory[il_policy]()
#     il_policy.multiagent_training = policy.multiagent_training
#     il_policy.safety_space = safety_space
#     robot.set_policy(il_policy)
#     explorer.run_k_episodes(il_episodes, 'train', update_memory=True, imitation_learning=True)  ##
#     trainer.optimize_epoch(il_epochs)  ##
#     torch.save(model.state_dict(), il_weight_file)
#     logging.info('Finish imitation learning. Weights saved.')
#     logging.info('Experience set size: %d/%d', len(memory), memory.capacity)
explorer.update_target_model(model)

I have tried, but it surprises me that the first Val got success rate 1. Is there something wrong with the change? How to achieve only-RL training?

I really need your help. Thanks~