[go: nahoru, domu]

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 implement embedding + mask in torch 1.12? #117

Open
pingguokiller opened this issue Sep 24, 2019 · 2 comments
Open

How to implement embedding + mask in torch 1.12? #117

pingguokiller opened this issue Sep 24, 2019 · 2 comments

Comments

@pingguokiller
Copy link

In rnn/utils.py

The below code is meaning add a mask to embeding. But it run error at torch 1.12. Does anyone know to realize it at torch 1.12? Thank you!

X = embed._backend.Embedding.apply(words, masked_embed_weight,
padding_idx, embed.max_norm, embed.norm_type,
embed.scale_grad_by_freq, embed.sparse
)

@dxbdxx
Copy link
dxbdxx commented Oct 10, 2019

Maybe it's torch.nn.functional.embedding(). The functions' parameters are similar but I am not sure they are the same.

@william-yl-gu
Copy link

I solved this problem by changing this code. The solution is referred from [site1] and [site2]

Replace:

    X = embed._backend.Embedding.apply(words, masked_embed_weight,
                                       padding_idx, embed.max_norm, embed.norm_type,
                                       embed.scale_grad_by_freq, embed.sparse
                                       )

with:

  from torch.nn import functional as F
  ...
  X = F.embedding(
       words, masked_embed_weight,
       padding_idx,
       embed.max_norm, embed.norm_type,
       embed.scale_grad_by_freq, embed.sparse
   )

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

3 participants