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

How to embedding segment lable #19

Closed
waallf opened this issue Oct 22, 2018 · 3 comments
Closed

How to embedding segment lable #19

waallf opened this issue Oct 22, 2018 · 3 comments
Labels
question Further information is requested

Comments

@waallf
Copy link

waallf commented Oct 22, 2018

Thanks for you code ,which let me leran more details for this papper .But i cant't understand segment.py. You haven't writeen how to embedding segment lable .

@codertimo
Copy link
Owner

@waallf It's just embedding with vocab size 2, which element is sentence A and sentence B.
So I inherit the nn.Embedding and initialized with vocab_size 2

@codertimo codertimo added the question Further information is requested label Oct 23, 2018
@nateraw
Copy link

nateraw commented Oct 23, 2018

More concretely, he sets this embedding to be of shape (2 + 1, embed_size) where:

  • 2 is the number of segments in the input
  • 1 is an additional index is for padding. It is initialized as zeros, as-per the Pytorch Documentation

We keep the same embedding space as the other embeddings so that we can add them together later.

import torch.nn as nn


class SegmentEmbedding(nn.Embedding):
    def __init__(self, embed_size=512):
        super().__init__(3, embed_size, padding_idx=0)

@codertimo this can probably be closed.

@faatemehch
Copy link

hi, thank you for the code it's really helpful. but i have an issue!
what is segment_info actually? i mean what should we write here?

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

No branches or pull requests

4 participants