hughperkins / pytorch

Python wrappers for torch and lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Load trained model

edgarriba opened this issue · comments

@hughperkins Do you support load an existing trained model?

Yes! I mean, on the lua side anyway. For example, you can have a look at https://github.com/hughperkins/pytorch-residual-networks/blob/pytorch/residual_trainer.lua#L58

But I guess you mean, can I load a .t7 directly into a Pytorch tensor, from the Python side? In which case... I need to think about that :-P

Yes, second use case. I want to interact with opencv python and a t7 file

Ok. Started looking at this in 6aa2f19 Seems like save maybe works. You might be able to add in load, using same approach? Otherwise I will look at this tomorrow-ish

thx!

Implemented in 0f129c0 You should be able to do:

import PyTorchAug

PyTorchAug.save('/tmp/foo.t7', sometensor)
result = PyTorchAug.load('/tmp/foo.t7')

You can look at test/test_save_load.py for an example

Can you confirm this does/doesnt work?

@hughperkins This works fine, thanks for this great work!

Cool. Thank you @sunshineatnoon :-)

Can I load a Gpu-trained model ? I mean the parameter of the model is CudaTensor. Thanks

Still not clear how to use trained model. I can use torch.load(file_path) to get the weights, but how do I use these weights to initialize the network? Thank you.