Loading Torch7 trained models (.t7) in PyTorch

Arul picture Arul · Jan 25, 2017 · Viewed 14.3k times · Source

I am using Torch7 library for implementing neural networks. Mostly, I rely on pre-trained models. In Lua I use torch.load function to load a model saved as torch .t7 file. I am curious about switching to PyTorch( http://pytorch.org) and I read the documents. I couldn't find any information regarding the mechanisms to load a pre-trained model. The only relevant information I was able to find is this page:http://pytorch.org/docs/torch.html

But the function torch.load described in the page seems to load a file saved with pickle. If someone has additional information on loading .t7 models in PyTorch, please share it here.

Answer

elyase picture elyase · Feb 8, 2017

The correct function is load_lua:

from torch.utils.serialization import load_lua

x = load_lua('x.t7')