2016-04-24 68 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

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