pfnet / pfrl

PFRL: a PyTorch-based deep reinforcement learning library
MIT License
1.18k stars 158 forks source link

Recurrent model with two types of inputs [question] #79

Closed tkelestemur closed 3 years ago

tkelestemur commented 4 years ago

I've been trying to implement a recurrent model for the PPO agent that can take two different types of observations. My environment has a Tuple observation space and consists a 2-channel image and a timeseries data. I want to feed the images into a series of 2d-conv layers and feed the time series into 1d-conv data. The output of these layers would be flattened and feed into a fully connected layer and output of the this layer would go into an LSTM.

My plan is to implement a torch.nn.Module subclass in which the forward function takes the tuple of observations and feed the them into corresponding layers and returns the output of the fully connected layer. Finally, I would put this model inside the pfrl.nn.RecurrentSequential.

This was the only way I could think of implementing this, however, I'm not sure it would work since the tuple observations might break something in the data collection. If this wouldn't work, how I can deal with using two types of observations and recurrent model?

muupan commented 3 years ago

My plan is to implement a torch.nn.Module subclass in which the forward function takes the tuple of observations and feed the them into corresponding layers and returns the output of the fully connected layer. Finally, I would put this model inside the pfrl.nn.RecurrentSequential.

I think this should work.

muupan commented 3 years ago

Feel free to reopen if it didn't work.

tarokiritani commented 3 years ago

I am trying to do this in #128. @tkelestemur if you have made this work, can I see how inputs are passed to your NN?

tkelestemur commented 3 years ago

@tarokiritani answered in your question.