lupa icon indicating copy to clipboard operation
lupa copied to clipboard

Numpy support?

Open albertz opened this issue 8 years ago • 3 comments

Hey,

I didn't found any information regarding Numpy (PyArrayObject), so I guess it's not supported. A translation between Numpy and maybe Torch's Lua Tensor (THTensor) would be nice.

Do you know if there is any project or code out there which does that?

THTensor, saved via LuaT.

PyArrayObject.

albertz avatar Mar 14 '16 16:03 albertz

I found some code here.

albertz avatar Mar 14 '16 16:03 albertz

You can look through the github forks: https://github.com/scoder/lupa/network It seems that a couple of people have attempted it, e.g. https://github.com/cstraehl/lupa Someone's also tried to interface with Torch: https://github.com/imodpasteur/lutorpy So far, no-one has tried to merge their work back into Lupa, though.

scoder avatar Mar 27 '16 12:03 scoder

Hi,

Our team is working on the fork version of lupa named lutorpy, for interfacing between numpy and torch.Thank lupa for enabling us to have such a nice way to use lua in python.

For using numpy with torch, you have two function tensor.asNumpyArray() and torch.fromNumpyArray() to convert from/to numpy array. With tensor.asNumpyArray(), the memory is shared between numpy array and torch tensor if you have a contiguous tensor.

And there are other stuff I am working on to make it more easier to use torch in python, for example, we introduced "._" syntax for replacing ":" operator in lua, so you can use tensor._size() for accesing size(), just like tensor:size() in lua. With that you can easily convert lua code into python.

Check https://github.com/imodpasteur/lutorpy for more details.

Any kind of contribution are highly appreciated.

oeway avatar May 03 '16 11:05 oeway