Load_lua got unknown Lua class

Hi,
I want to load Lua model like this,

model = Net()
model.cuda()
from torch.utils.serialization import load_lua
model.load_state_dict(load_lua(’/home/nn4.small2.v1.t7’))

But I got unknown class and can not load model, is there anyway to fix it?
/home/lab/yifan/venv/local/lib/python2.7/site-packages/torch/utils/serialization/read_lua_file.pyc in read_object(self)
538 "{}. If you want to ignore this error and load this object "
539 "as a dict, specify unknown_classes=True in reader’s "
–> 540 “constructor”).format(cls_name))
541
542 def _can_be_list(self, table):

T7ReaderException: don’t know how to deserialize Lua class nn.SpatialConvolutionMM. If you want to ignore this error and load this object as a dict, specify unknown_classes=True in reader’s constructor

Thanks a lot!

a workaround is given right in the error message.

Thanks Smith!
I try that but it turns out AttributeError: ‘SpatialBatchNormalization’ object has no attribute ‘running_var’

that checkpoint is REALLY old, even by torch standards. Please load the checkpoint in torch and save it again, and then load it in pytorch.

Hi, I faced the same problem once with “nn.SpatialConvolutionMM.”.
To overcome this, I used the following script:
https://raw.githubusercontent.com/soumith/cudnn.torch/master/convert.lua
(provided by @smth)

  • which allowed me to convert SpatialConvolutionMM to SpatialConvolution

Hope this helps.

Hi,

Do we have a solution for this?