ray icon indicating copy to clipboard operation
ray copied to clipboard

[Question] How to obtain the action embedding for avail_action ?

Open soloist96 opened this issue 7 years ago • 9 comments

This is a general question about parametric action space but I think people here may know the solution. I try to embed the action but in the toy model given by rllib, the available action embedding are generated randomly in the env. Shouldn't be the embeddings learned? For example, for word2vec, it's learned from corpus. For a more practical RL problem, how could we obtain those embeddings? Thank you.

soloist96 avatar Aug 26 '19 16:08 soloist96

You can certainly try to learn it, that's up to you. To do that you can have a random embedding matrix instead of fixed values.

ericl avatar Aug 26 '19 20:08 ericl

Thank you Eric for the reply. I am wondering if you could provide me with some instructions on a common way to learn the weights? In my understanding, is this equivalent with adding a fully connected layer (weights is embedding size x number of actions) at the end of my model (say my model outputs the dimension of embedding size) so that the output becomes the logits desired? In that case, it is equivalent of modifying network architecture and I don't see the meaning of introducing parametric actions.

I try to mimic how openAI embed the Dota action space but could not find any detailed explanations about how to learn the action embedding matrix.

Thank you!

soloist96 avatar Aug 26 '19 21:08 soloist96

You want to go from action (0..N index) to a fixed size embedding (size M) right? The typical way to do this is to multiply by a matrix of size (NxM), which can be learnable. This gives you your action embeddings.

Edit: note that the "multiply" is just a lookup in the embedding table (it's equivalent to a multiply if the action index is one-hot encoded). You can take a look at torch.nn.Embedding for an example of how it works.

On Mon, Aug 26, 2019, 2:21 PM soloist96 [email protected] wrote:

Thank you Eric for the reply. I am wondering if you could provide me with some instructions on a common way to learn the weights? In my understanding, is this equivalent with adding a fully connected layer (weights is embedding size x number of actions) at the end of my model (say my model outputs the dimension of embedding size) so that the output becomes the logits desired? In that case, it is equivalent of modifying network architecture and I don't see the meaning of introducing parametric actions.

I try to mimic how openAI embed the Dota action space but could not find any detailed explanations about how to learn the action embedding matrix.

Thank you!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ray-project/ray/issues/5540?email_source=notifications&email_token=AAADUSWOGQFSQCHFWZGI2O3QGRCPLA5CNFSM4IPRHSX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5FXC3Y#issuecomment-525037935, or mute the thread https://github.com/notifications/unsubscribe-auth/AAADUSTRSBQYVDXIDDROCQDQGRCPLANCNFSM4IPRHSXQ .

ericl avatar Aug 26 '19 21:08 ericl

Thank you Eric. Yes, I want to go from an action to an embedding. And I know how the embedding table works. And my confuse is about how to use the RLlib framework to learn this embedding. For NLP problems, people can use Cbow or GloVe to train on corpus to get this embedding. However, in the RL framework, I am not clear how we get those embeddings for actions.

Are we expected to incorporate this embedding matrix in the policy neural network to get the weights learned? Thanks a lot.

soloist96 avatar Aug 28 '19 15:08 soloist96

Yes, it should be part of your model weights and is trained via backprop?

On Wed, Aug 28, 2019, 8:13 AM soloist96 [email protected] wrote:

Thank you Eric. Yes, I want to go from an action to an embedding. And I know how the embedding table works. And my confuse is about how to use the RLlib framework to learn this embedding. For NLP problems, people can use Cbow or GloVe to train on corpus to get this embedding. However, in the RL framework, I am not clear how we get those embeddings for actions.

Are we expected to incorporate this embedding matrix in the policy neural network to get the weights learned? Thanks a lot.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ray-project/ray/issues/5540?email_source=notifications&email_token=AAADUSSNRDUUEHGRHIVQHU3QG2IYVA5CNFSM4IPRHSX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5LO3JI#issuecomment-525790629, or mute the thread https://github.com/notifications/unsubscribe-auth/AAADUSWMKYV4BWGANIVNYTLQG2IYVANCNFSM4IPRHSXQ .

ericl avatar Aug 28 '19 17:08 ericl

Yeah, I agree! Thanks a lot!

soloist96 avatar Aug 29 '19 22:08 soloist96

@soloist96 Interesting discussion. Did you find an easy way of doing the suggested embedding training technique?

nMack429 avatar Mar 05 '20 13:03 nMack429

Hi, I'm a bot from the Ray team :)

To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months.

If there is no further activity in the 14 days, the issue will be closed!

  • If you'd like to keep the issue open, just leave any comment, and the stale label will be removed!
  • If you'd like to get more attention to the issue, please tag one of Ray's contributors.

You can always ask for help on our discussion forum or Ray's public slack channel.

stale[bot] avatar Nov 14 '20 10:11 stale[bot]

Hi again! The issue will be closed because there has been no more activity in the 14 days since the last message.

Please feel free to reopen or open a new issue if you'd still like it to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for opening the issue!

stale[bot] avatar Nov 28 '20 10:11 stale[bot]