I am trying to save some tables of strings to files in Torch. I have tried using this Torch extension by Deepmind: hdf5.
require 'hdf5'
label = {'a', 'b','c','d'}
local myFile = hdf5.open(features_repo .. 't.h5', 'w')
myFile:write('label', label)
myFile:close()
I am getting the error:
/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
Torch Tensors are written to file as intended.
I have also tried using matio to write to mat files (for MatLab). I am getting this error:
bad argument #1 to 'varCreate' (cannot convert 'number' to 'const char *')
The error is because "label" is a table of strings, but the function HDF5Group:_writeData
is expecting a form of "tensor".
Looking at ffi.lua
, it seems that the "tensor" is a typedef for "integer", so maybe replace:
label = {'a', 'b','c','d'}
with label = {1,2,3,4}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With