-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.lua
59 lines (45 loc) · 1.3 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
-- @author Sachin Mehta
--- -----
-- Module to start training
-- @module main
require 'torch'
require 'paths'
require 'optim'
require 'nn'
torch.setdefaulttensortype('torch.FloatTensor')
--- parse the command line arguments
local opts = require 'opts'
opt = opts.parse(arg) --global variable (can be accessed across files)
opt.cacheDir = opt.dataCache .. '/' .. opt.dataset
opt.dataCacheFileName = opt.cacheDir .. '/data.t7'
if opt.dataset == 'mel' then
if not paths.filep(opt.dataCacheFileName) then
print('Loading Melanoma dataset from loadMel')
require 'loadMel'
else
print('loading cached Melanoma file')
end
dataset = torch.load(opt.dataCacheFileName)
else
print('Wrong dataset specified. Please check')
print('Exiting')
os.exit()
end
--number of classes in the dataset
opt.classes = dataset.classes
print(opt.classes)
opt.classWeight = dataset.classWeight
print(opt.classWeight)
print('Dataset has ' .. opt.classes .. ' classes including background')
-- load the model
local models = require 'init'
model, criterion, epochNo = models.modelSetup()
local train = require 'train'
local test = require 'test'
--test(-1, dataset)
-- start training and validation
for ep = epochNo, opt.maxEpoch do
model, criterion, confusionMat = train(ep, dataset)
test(ep, dataset)
collectgarbage()
end