2016-04-24 39 views
9

我想將一些字符串表格保存到火炬中的文件中。我曾嘗試使用Deepmind的這個Torch擴展:hdf5在火炬中寫表格到文件

require 'hdf5' 
label = {'a', 'b','c','d'} 

local myFile = hdf5.open(features_repo .. 't.h5', 'w') 
myFile:write('label', label) 
myFile:close() 

我收到錯誤:

/home/user/torch/install/bin/luajit: ...e/user/torch/install/share/lua/5.1/hdf5/group.lua:222: torch-hdf5: writing data of type string is not supported 

火炬張量寫成旨在文件。

我也嘗試使用matio寫入mat文件(對於MatLab)。我收到此錯誤:

bad argument #1 to 'varCreate' (cannot convert 'number' to 'const char *') 

回答

2

的錯誤是因爲「標籤」是一個字符串表,但功能HDF5Group:_writeData期待「張量」的一種形式。在ffi.lua

來看,似乎 「張」 是 「整數」 一個typedef,所以也許替換:

label = {'a', 'b','c','d'} 

與 標籤= {1,2,3,4}

+0

不幸的是我需要保存字符串。 –