Skip to content

Instantly share code, notes, and snippets.

@deltheil
Created April 4, 2015 16:31
Show Gist options
  • Save deltheil/8a7e0d384a5bc0ca97a8 to your computer and use it in GitHub Desktop.
Save deltheil/8a7e0d384a5bc0ca97a8 to your computer and use it in GitHub Desktop.
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