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

LookupTable implementation #29

Open
ez81 opened this issue Feb 2, 2018 · 1 comment
Open

LookupTable implementation #29

ez81 opened this issue Feb 2, 2018 · 1 comment

Comments

@ez81
Copy link

ez81 commented Feb 2, 2018

I was trying to implement the LookupTable. However the output does not match that from the original torch model. I used the nn.Embedding module and copied the weight tensor from the torch LookupTable. What could be wrong here?

Additional condition in lua_recursive_model

elif name == 'LookupTable':
            n1 = Lambda(lambda x: x.view(1,-1) if 1==len(x.size()) else x )
            n2 = nn.Embedding(m.weight.size(0),m.weight.size(1))
            n2.weight.data.copy_(m.weight)
            n = nn.Sequential(n1,n2)
            add_submodule(seq,n)

Additional condition in lua_recursive_source

elif name == 'LookupTable':
            s1 = 'Lambda(lambda x: x.view(1,-1) if 1==len(x.size()) else x )'
            s2 = 'nn.Embedding({},{})'.format(m.weight.size(0),m.weight.size(1))
            s += ['nn.Sequential({},{}),#LookupTable'.format(s1,s2)]
@zeng9t
Copy link

zeng9t commented Dec 24, 2019

Have you solved that? I have the problem of LookupTable when transfer the lua/torch code to pytorch code. @YZHANGFPE

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

2 participants