-
Notifications
You must be signed in to change notification settings - Fork 3
/
run-gpu.lua
49 lines (40 loc) · 1.58 KB
/
run-gpu.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
49
----------------------------------------------------------------------
-- Train a ConvNet on cifar
-- Original : Clement Farabet
----------------------------------------------------------------------
require 'pl'
require 'torch'
----------------------------------------------------------------------
print '==> processing options'
opt = lapp[[
-r,--learningRate (default 2e-3) learning rate
-d,--learningRateDecay (default 0) learning rate decay)
-w,--weightDecay (default 0) L2 penalty on the weights
-m,--momentum (default 0.9) momentum
-d,--dropout (default 0.5) dropout amount
-b,--batchSize (default 64) batch size
-t,--threads (default 8) number of threads
-i,--devid (default 1) device ID
-o,--save (default results) save directory
]]
-- nb of threads and fixed seed (for repeatable experiments)
torch.setnumthreads(opt.threads)
torch.manualSeed(1)
torch.setdefaulttensortype('torch.FloatTensor')
require 'cutorch'
require 'cunn'
cutorch.setDevice(opt.devid)
print('==> using GPU #' .. cutorch.getDevice())
print(cutorch.getDeviceProperties(opt.devid))
cutorch.manualSeed(1)
----------------------------------------------------------------------
print '==> load modules'
local data = require 'data'
local train = require 'train'
local test = require 'test'
----------------------------------------------------------------------
print '==> training!'
while true do
train(data.trainData)
test(data.testData)
end