torch / torch7

http://torch.ch
Other
8.96k stars 2.38k forks source link

Loading tensors saved in PyTorch in Torch? #1152

Open stu17682 opened 6 years ago

stu17682 commented 6 years ago

Hi guys

I have a tensor saved, as follows:

finalTensor = torch.from_numpy(apiTensor) torch.save(finalTensor, ‘finalTensor.stu’)

It saves, and loads, in PyTorch fine.

Problem is when I try and load it in Torch like this:

apiCallsFile = ‘some/path/to/finalTensor.stu’ local rawAPICalls = torch.load(apiCallsFile)

I get this error:

/home/smillar/torch/install/bin/luajit: /home/smillar/torch/install/share/lua/5.1/torch/File.lua:375: unknown object stack traceback: [C]: in function ‘error’ /home/smillar/torch/install/share/lua/5.1/torch/File.lua:375: in function ‘readObject’ /home/smillar/torch/install/share/lua/5.1/torch/File.lua:409: in function ‘load’ ./prepareAPICallsEmbedding.lua:70: in function ‘prepareAPICallsEmbedding’ DetectMalware_CNN.lua:269: in main chunk [C]: in function ‘dofile’ …llar/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk [C]: at 0x00405d50

I suspect the pickling when saving in PyTorch has something to do with it. And the path for ‘apiCallsFile’ is correct.

Is there any way to do this?

Thanks!

S.

greed2411 commented 6 years ago

@stu17682 check this comment from the pytorch discussion forum. hope it helps. link to comment