Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

training issue #49

Open
ShelyH opened this issue Jan 24, 2022 · 2 comments
Open

training issue #49

ShelyH opened this issue Jan 24, 2022 · 2 comments

Comments

@ShelyH
Copy link

ShelyH commented Jan 24, 2022

Hi,sorry to bother you.
I don't want to imitate learning,so I set 'imitation_learning=False' in train.py,but there are some error:
AttributeError: 'JointState' object has no attribute 'unsqueeze' File "train.py", line 188, in
main()
File "train.py", line 140, in main
explorer.run_k_episodes(il_episodes, 'train', update_memory=True, imitation_learning=False)
File "../crowd_nav/utils/explorer.py", line 72, in run_k_episodes
self.update_memory(states, actions, rewards, imitation_learning)
File "../crowd_nav/utils/explorer.py", line 116, in update_memory
value = reward + gamma_bar * self.target_model(next_state.unsqueeze(0)).data.item()
AttributeError: 'JointState' object has no attribute 'unsqueeze'

Can you tell me how to solve it?Thanks very much!

@ChanganVR
Copy link
Contributor

@2529342549 if you don't want to run imitation learning, you should comment out these lines altogether instead of just setting that variable to False:

CrowdNav/crowd_nav/train.py

Lines 116 to 133 in 20d6780

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)

Let me know if this fix works for you.

@ShelyH
Copy link
Author

ShelyH commented Feb 26, 2022

Hi, thanks for your last answer,I'm here to disturb you again。
During training, the model is evaluated every 1000 intervals,the purpose of this is to show how good or bad the current model is or if there are other intentions?
# evaluate the model if episode % evaluation_interval == 0: explorer.run_k_episodes(env.case_size['val'], 'val', episode=episode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants