Shuijing725 / CrowdNav_DSRNN

[ICRA 2021] Decentralized Structural-RNN for Robot Crowd Navigation with Deep Reinforcement Learning
https://sites.google.com/illinois.edu/crowdnav-dsrnn/home
MIT License
97 stars 23 forks source link

Dynamic changing number of humans #6

Closed mincheulkim closed 2 years ago

mincheulkim commented 3 years ago

Hi, I wonder this simulation can be applied to the dynamic changing number of people.

Since the hidden states and spatial edges are dependent on human_num, it seems to cause a problem in the forward() of srnn_model.py if the number of people changes at every step.

Where am I missing something?

Thanks,

Shuijing725 commented 3 years ago

Short answer: Yes, but it will either make the network slower or performs worse.

Long answer: Because of the batch operation, the network's input dimension has to be the same at all times, so we need to keep the shape of observation the same. To do this with changing number of humans, in the gym environment, you can set the number of people to a maximum limit and use some special numbers like -1 to represent the people not present at each timestep. However, the above fix may affect the network's performance since the human trajectories are less continuous. A possible solution is to create a mask to indicate whether each human is present at each timestep (similar to the done mask), but you will have to use a for loop in the forward function to iterate through all humans, which makes it slower.

mincheulkim commented 3 years ago

Thanks for your kind explanation, Unfortunately, I'm not good at understanding below suggestions in your explanation.

  1. What is the difference between assigning specific number(e.g. -1) and mask to non-existent person at each time step?
  2. At the end of the explanation, what does it mean to use a mask for loop in the forward function to iterate through all humans?

Thanks,

Shuijing725 commented 3 years ago

I've been working on changing number of humans recently, so I apologize if I'm inconsistent with my own words earlier.

  1. Using dummy humans (-1) will introduce bias to the RNNs, while masking won't. But masking takes more work to implement.
  2. I meant in the forward function of the RNN in pytorchBaselines/a2c_ppo_acktr/srnn_model.py. But I now realized for loop is not necessary if you combine the done masks and this non-existent mask.
mincheulkim commented 2 years ago

Thanks!