-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScript.lua
48 lines (40 loc) · 1.3 KB
/
Script.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package.path = package.path .. ';Models/?.lua' --define path for Models
model = require 'Alexnet_eladhoffer' -- Select the model
model = model:cuda()
print(model)
require 'mattorch'
-- load the luminance
--local trainx = mattorch.load('trainX.mat') -- training data samples
--local trainy = mattorch.load('trainY.mat')
--local testx = mattorch.load('testX.mat')
----local testy = mattorch.load('testY.mat')
trainset = {}
trainset.data = torch.rand(200,15,64,64):cuda()
temp1 = torch.rand(200)
for i=1,200 do temp1[i] = math.random(1,101) end
trainset.label = torch.rand(200,1)
trainset.label[{{},1}] = temp1
trainset.label = trainset.label:cuda()
--trainset.data = trainx.train:cuda()
--trainset.label = trainy.trainY:cuda()
print(trainset)
testset = {}
testset.data = torch.rand(50,15,64,64):cuda()
temp2 = torch.rand(50)
for i=1,50 do temp1[i] = math.random(1,101) end
testset.label = torch.rand(50,1)
testset.label[{{},1}] = temp2
testset.label = testset.label:cuda()
--testset.data = testx.vid_data:cuda()
--testset.data = testy.Y:cuda()
print(testset)
setmetatable(trainset,
{__index = function(t, i)
return {t.data[i], t.label[i]}
end}
);
criterion = nn.ClassNLLCriterion()
criterion = criterion:cuda()
function trainset:size()
return self.data:size(1)
end