Created
April 4, 2015 16:31
-
-
Save deltheil/8a7e0d384a5bc0ca97a8 to your computer and use it in GitHub Desktop.
http://stackoverflow.com/a/29257879/1688185 (csv -> Torch7 tensor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'torch' | |
-- pre-req: luarocks install csv | |
local csv = require "csv" | |
local inputs, labels = {}, {} | |
local f, i = csv.open("data.csv"), 0 | |
for fields in f:lines() do | |
if i > 0 then -- skip header | |
inputs[i] = {unpack(fields, 1, 18)} | |
labels[i] = fields[19] | |
end | |
i = i + 1 | |
end | |
inputs = torch.Tensor(inputs) | |
labels = torch.Tensor(labels) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment