Numpy format for Torch
Switch branches/tags
Clone or download
htwaijry Merge pull request #14 from willfrey/patch-1
thanks! .. Update CMakeLists.txt
Latest commit 7b51d07 Mar 15, 2017
Permalink
Failed to load latest commit information.
cnpy
CMakeLists.txt
LICENSE
README.MD
init.lua
npy4th-1.3-3.rockspec
npy4th.cpp

README.MD

#npy4th

A package to load/save numpy files for torch7.

Reads .npy and .npz files, and stores torch.*Tensor in .npy format.

Requirements

  • torch7
  • xlua

Installation

You can install the package as follows:

git clone https://github.com/htwaijry/npy4th.git
cd npy4th
luarocks make

Use

npy4th = require 'npy4th'

-- read a .npy file into a torch tensor
array = npy4th.loadnpy('array.npy')

-- read a .npz file into a table
tbl = npy4th.loadnpz('table.npz')

-- save a torch.*Tensor into a .npy file
myTensor = torch.Tensor({1,2,3})
npy4th.savenpy('tensor.npy', myTensor)

-- append a torch.*Tensor to an existing .npy file
myTensor2 = torch.Tensor({4,5,6})
npy4th.savenpy('tensor.npy', myTensor2, 'a')