GithubHelp home page GithubHelp logo

soumith / matio-ffi.torch Goto Github PK

View Code? Open in Web Editor NEW
39.0 39.0 28.0 36 KB

A LuaJIT FFI interface to MATIO and simple bindings for torch

License: BSD 3-Clause "New" or "Revised" License

Lua 98.60% MATLAB 1.40%

matio-ffi.torch's People

Contributors

alexandermelde avatar elpiloto avatar fmassa avatar hpenedones avatar koraykv avatar maxvonhippel avatar mys007 avatar soumith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

matio-ffi.torch's Issues

Matio won't load .mat files

Hey,

My matio was installed from the ubuntu repo and I did follow up with luarocks install matio but it seems the devils are really unhappy with me:

th> tensor = matio:load('vicon.mat', 'vicon')
[string "tensor = matio:load('vicon.mat', 'vicon')"]:1: attempt to index global 'matio' (a nil value)
stack traceback:
[string "tensor = matio:load('vicon.mat', 'vicon')"]:1: in main chunk
[C]: in function 'xpcall'
/home/lex/torch/install/share/lua/5.1/trepl/init.lua:668: in function 'repl'
.../lex/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x00406670

Matlab versioon is 8.6.0.267246 (R2015b).

Any ideas?

Can't require 'matio'

The issue is as bellow:

/home/wanggu/torch/install/share/lua/5.1/matio/ffi.lua:20: /usr/local/lib/libmatio.so.2: undefined symbol: H5T_NATIVE_SCHAR_g
stack traceback:
        [C]: in function 'load'
        /home/wanggu/torch/install/share/lua/5.1/matio/ffi.lua:20: in function </home/wanggu/torch/install/share/lua/5.1/matio/ffi.lua:20>
        [C]: in function 'xpcall'
        /home/wanggu/torch/install/share/lua/5.1/matio/ffi.lua:20: in main chunk
        [C]: at 0x0046b7a0
        [C]: in function 'pcall'
        /home/wanggu/torch/install/share/lua/5.1/trepl/init.lua:380: in function 'require'
        /home/wanggu/torch/install/share/lua/5.1/matio/init.lua:3: in main chunk
        [C]: at 0x0046b7a0
        [C]: in function 'pcall'
        /home/wanggu/torch/install/share/lua/5.1/trepl/init.lua:380: in function 'require'
        [string "_RESULT={require 'matio'}"]:1: in main chunk
        [C]: in function 'xpcall'
        /home/wanggu/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
        ...nggu/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
        [C]: at 0x00406670
/home/wanggu/torch/install/share/lua/5.1/trepl/init.lua:384: /home/wanggu/torch/install/share/lua/5.1/trepl/init.lua:384: /home/wanggu/torch/install/share/lua/5.1/matio/ffi.lua:24: Could not find libmatio. Please make sure that you installd MatIO and you have the shared libraries (libmatio.so or libmatio.dylib) in your library path
stack traceback:
        [C]: in function 'error'
        /home/wanggu/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require'
        [string "_RESULT={require 'matio'}"]:1: in main chunk
        [C]: in function 'xpcall'
        /home/wanggu/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
        ...nggu/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
        [C]: at 0x00406670

@soumith How can I fix this?

Unable to load the mat file and the format mat file to be saved

I am going to load a normal ''.mat" file in the torch. But it has following eror:

Segmentation fault: 11

And I am trying to re-save the data in the matlab with compatible format, but I found that the command in the "test" directory is a bit confusing, the command "save -mat7-binary 'test.mat' a" has made me confused. Does anyone know how to save the ".mat" file correctly so that I can load it in the torch?

Thank you so much.

Memory leak on loading mat file

I am sure there is memory leak after loading mat files. After loading lots of '.mat' files, the memory is occupied.

I tried to add 'mat.varFree()' before 'mat.close()'. But it didn't seem to help.

How to save a table of strings in using matio.save?

my intention is to save a list of strings from lua to mat file.

t = {}
t[1] = 'Tom'
t[2] = 'Jerry'
matio = require 'matio'
matio.save('test.mat', t)

with the above code I get the following error:
bad argument #1 to 'varCreate' (cannot convert 'number' to 'const char *')

Is there any way to store a list of strings from lua to mat file?

libmatio.so cannot open issue

I followed the instruction to install matio package. However, require 'matio' throws an exception. libmatio.so: cannot open shared object file
I spent some time to investigate this issue. It turns out the lib file name is mismatched.

My solution is ln -s /usr/lib/x86_64-linux-gnu/libmatio.so.2 /usr/lib/x86_64-linux-gnu/libmatio.so (my environment is Ubuntu 14.04.1 X64 desktop version.)

Is it common issue in Ubuntu? I suggest to put a notification in README.md for this issue.

matio not found for Lua 5.3 5.2 5.1

$luarocks install matio
matio not found for Lua 5.2.
Checking if available for other Lua versions...
Checking for Lua 5.1...
Checking for Lua 5.3...
Checking for Lua 5.4...

Error: No results matching query were found for Lua 5.2.

installing using libmatio4 (Ubuntu 18.04)

Hello,

i was following the installation guide and noticed that libmatio2 is not in the package repository for the Ubuntu 18.04 LTS i am using. I did instead install the newer version libmatio4 by using sudo apt install libmatio4.

The next command luarocks install matio finishes without errors as well. It installs the matio module to ~/torch/install/lib/luarocks/rocks/matio.

Unfortunately, i cant import the module in a torch script. Using the torch interactive console th to test local matio = require 'matio' results in the following error message:

th> local matio = require 'matio'
/home/alexander/torch/install/share/lua/5.1/matio/ffi.lua:20: libmatio.so.2: cannot open shared object file: No such file or directory
stack traceback:
	[C]: in function 'load'
	/home/alexander/torch/install/share/lua/5.1/matio/ffi.lua:20: in function </home/alexander/torch/install/share/lua/5.1/matio/ffi.lua:20>
	[C]: in function 'xpcall'
	/home/alexander/torch/install/share/lua/5.1/matio/ffi.lua:20: in main chunk
	[C]: at 0x565451a2be70
	[C]: in function 'pcall'
	/home/alexander/torch/install/share/lua/5.1/trepl/init.lua:385: in function 'require'
	/home/alexander/torch/install/share/lua/5.1/matio/init.lua:3: in main chunk
	[C]: at 0x565451a2be70
	[C]: in function 'pcall'
	/home/alexander/torch/install/share/lua/5.1/trepl/init.lua:385: in function 'require'
	[string "local matio = require 'matio'"]:1: in main chunk
	[C]: in function 'xpcall'
	/home/alexander/torch/install/share/lua/5.1/trepl/init.lua:679: in function 'repl'
	...nder/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:204: in main chunk
	[C]: at 0x5654519c7570	
/home/alexander/torch/install/share/lua/5.1/trepl/init.lua:389: /home/alexander/torch/install/share/lua/5.1/trepl/init.lua:389: /home/alexander/torch/install/share/lua/5.1/matio/ffi.lua:24: Could not find libmatio. Please make sure that you installd MatIO and you have the shared libraries (libmatio.so or libmatio.dylib) in your library path
stack traceback:
	[C]: in function 'error'
	/home/alexander/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
	[string "local matio = require 'matio'"]:1: in main chunk
	[C]: in function 'xpcall'
	/home/alexander/torch/install/share/lua/5.1/trepl/init.lua:679: in function 'repl'
	...nder/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:204: in main chunk
	[C]: at 0x5654519c7570	
                                                                      [0.0016s]	

I could resolve this error by creating the following symbolic link:
ln -s /usr/lib/x86_64-linux-gnu/libmatio.so.4 /usr/lib/x86_64-linux-gnu/libmatio.so

I will create a push request to update the readme.

Unsupported variable type: 5

I'm using matio.load to load a .mat file. It contains file arrays, xtrain, xtest, ytrain, ytest and vocab. matio got Unsupported variable type: 5 while loading xtrain and ytrain. And other three loaded correctly.

And the data file can be loaded correctly in matlab.

No variables in this file

This is on a system running Ubuntu 12.04. I installed matio using apt-get, and have MATLAB R2013a. The command to install matio, i.e. sudo luarocks install matio executes without any errors. However, when I start Torch, and try to read a MAT file, this is what happens:

matio = require 'matio'
tensor = matio.load('test.mat')
No variables in this file

If I exit Torch at this point, I find that the test.mat MAT file has been rewritten to an empty file of size 128 bytes.

Can't install

BrodskyMacBookPro:lua---mattorch jmcdonald$ brew install libmatio
Error: No available formula for libmatio
Searching formulae...
Searching taps...
homebrew/science/libmatio
BrodskyMacBookPro:lua---mattorch jmcdonald$ brew install homebrew/science/libmatio
==> Tapping homebrew/science
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-science'...
remote: Counting objects: 537, done.
remote: Compressing objects: 100% (533/533), done.
remote: Total 537 (delta 4), reused 160 (delta 3), pack-reused 0
Receiving objects: 100% (537/537), 421.22 KiB | 0 bytes/s, done.
Resolving deltas: 100% (4/4), done.
Checking connectivity... done.
Tapped 530 formulae (557 files, 2.8M)
==> Installing libmatio from homebrew/homebrew-science
==> Downloading https://downloads.sourceforge.net/project/matio/matio/1.5.2/matio-1.5.2.tar.gz

################################################################## 100.0%

Error: SHA1 mismatch
Expected: d5a83a51eb2550d75811d2dde967ef3e167d4f52
Actual: ea60df615387f47bdfdfe4da48f6567c4ec60f74
Archive: /Library/Caches/Homebrew/libmatio-1.5.2.tar.gz
To retry an incomplete download, remove the file above.

Any tips on getting this to work with Zero Brane Studio?

Hi,

I'm trying to use this with ZeroBrane Studio (ZBS) but for some reason, it won't open the file.
Command line torch works just fine as seen in the pic.

Currently using the Torch7 interpreter, but tried a few others too.

Has this got anything to do with this being a LuaJIT interface to MATIO?

image

undefined symbol H5T_NATIVE_SCHAR_g

Hello. I'm not familiar with Lua FFI, but I'm hitting this error (arch linux0:

/home/esimo/torch/install/share/lua/5.1/matio/ffi.lua:20: /usr/lib/libmatio.so.2: undefined symbol: H5T_NATIVE_SCHAR_g

As matio is not being linked to hdf5, if you were to compile against it you would have to link against hdf5 also. However, this is not being handled with the Lua FFI interface, and I'm not sure how to fix it, although it does seem like it should be trivial.

segmantation fault issue

I installed matio on ubuntu following the instructions, namely:


1. # apt-get install libmatio2
2. # luarocks install matio

when I tried to run this little testfile.lua :


local matio = require 'matio'
tensor1 = matio.load('testdata.mat')

with torch (# th testfile.lua), I got the following error:


Segmentation fault (core dumped)

No support for matlab 7.3 files

This is not a huge issue, but files saved in MATLAB 7.3 format are not supported. E.g

In MATLAB

test = magic(10)
save('test7.mat','test', '-v7')
save('test73.mat','test', '-v7.3')

In torch
matio = require 'matio'
input1 = matio.load('test7.mat', 'test')
input1 = matio.load('test73.mat', 'test') -- ERR: File could not be opened: test73.mat

Compare output value with integer

I am currently getting userdata as the type of gesture after loading from the repsective vector.
How can I possibly compare this value gesture with an integer?

My code looks as follows:
gesture = matio.load(val, 'gesture')

if gesture == 101 then
    gesture = th.FloatTensor({10})
    print("101 Detected! New value is: ")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.