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

can not convert from .t7 #2

Open
jjldr opened this issue Feb 22, 2019 · 4 comments
Open

can not convert from .t7 #2

jjldr opened this issue Feb 22, 2019 · 4 comments

Comments

@jjldr
Copy link

jjldr commented Feb 22, 2019

Thank you for sharing your code. But when i run the t7_to_pth.py with PyTorch 0.4.1, some error happens,the error is as follows:
File "t7_to_pth.py", line 93, in
model2[prefix+'conv_d.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[2].modules[0].modules[1].modules[1].weight
AttributeError: 'Sequential' object has no attribute 'weight'

please help me!

@jcdubron
Copy link
Owner

The pretrained model provided by the author has been updated and it might be a little bit different from the original version. A feasible way is to insert .modules[0] before .weight in lines between 93 and 96.

model2[prefix+'conv_d.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_u.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[140].modules[1].modules[2].modules[0].modules[0].weight
model2[prefix+'conv_r.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_l.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[396].modules[1].modules[2].modules[0].modules[0].weight

@jjldr
Copy link
Author

jjldr commented Feb 24, 2019

The pretrained model provided by the author has been updated and it might be a little bit different from the original version. A feasible way is to insert .modules[0] before .weight in lines between 93 and 96.

model2[prefix+'conv_d.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_u.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[140].modules[1].modules[2].modules[0].modules[0].weight
model2[prefix+'conv_r.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_l.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[396].modules[1].modules[2].modules[0].modules[0].weight

It works ! Thanks.

@HongJinZ
Copy link

HongJinZ commented Apr 2, 2019

Thank you for sharing your code. But when i run the t7_to_pth.py with PyTorch 0.4.1, some error happens,the error is as follows:
torch.utils.serialization.read_lua_file.T7ReaderException: unknown type id 968499410. The file may be corrupted.
And Baidu teaches me to use model trained by pytorch. How can I do? Please help me. Thank you very much.

@jcdubron
Copy link
Owner

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