Last active
August 29, 2015 14:04
-
-
Save smly/683f4e049a3942b87842 to your computer and use it in GitHub Desktop.
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
th = require 'torch' | |
mattorch = require 'fb.mattorch' | |
function main() | |
train_data = th.load('data/train_all.t7') | |
test_data = th.load('data/test_all.t7') | |
print("Convert train_all (mat)") | |
train_all_mat = {} | |
for i=1, #train_data do | |
train_all_mat[string.format('train%d', i)] = train_data[i][1] | |
end | |
mattorch.save('data/train_all_1.mat', train_all_mat) | |
print("Convert test_all (mat)") | |
test_all_mat = {} | |
for i=1, #test_data do | |
test_all_mat[string.format('test%d', i)] = test_data[i][1] | |
end | |
mattorch.save('data/test_all_1.mat', test_all_mat) | |
end | |
main() |
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' | |
m = require 'matio' | |
function convert_train_data(subject_id) | |
local fp = string.format('data/train_subject%02d.mat', subject_id) | |
local x = m.load(fp, 'X') | |
local y = m.load(fp, 'y') | |
local data = {} | |
for i=1,x:size(1) do | |
data[i] = {} | |
data[i][1] = x[i] -- i-th trial | |
data[i][2] = y[i] | |
end | |
torch.save(string.format('data/subject%02d.bin', subject_id), data) | |
end | |
function convert_test_data(subject_id) | |
local fp = string.format('data/test_subject%02d.mat', subject_id) | |
local x = m.load(fp, 'X') | |
local data = {} | |
for i=1,x:size(1) do | |
data[i] = {} | |
data[i][1] = x[i] -- i-th trial | |
end | |
torch.save(string.format('data/subject%02d.bin', subject_id), data) | |
end | |
function main() | |
for i=1,16 do | |
print(string.format("Convert %s", i)) | |
convert_train_data(i) | |
end | |
for i=17,23 do | |
print(string.format("Convert %s", i)) | |
convert_test_data(i) | |
end | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment