openface/training/main.lua

51 lines
959 B
Lua
Raw Normal View History

#!/usr/bin/env th
require 'torch'
require 'optim'
require 'paths'
require 'xlua'
local opts = paths.dofile('opts.lua')
opt = opts.parse(arg)
print(opt)
2016-01-12 04:36:58 +08:00
if opt.cuda then
require 'cutorch'
2016-06-15 03:55:46 +08:00
cutorch.setDevice(opt.device)
2016-01-12 04:36:58 +08:00
end
torch.save(paths.concat(opt.save, 'opts.t7'), opt, 'ascii')
print('Saving everything to: ' .. opt.save)
torch.setdefaulttensortype('torch.FloatTensor')
torch.manualSeed(opt.manualSeed)
paths.dofile('data.lua')
paths.dofile('util.lua')
2016-06-29 17:48:03 +08:00
model = nil
criterion = nil
paths.dofile('train.lua')
paths.dofile('test.lua')
if opt.peoplePerBatch > nClasses then
print('\n\nError: opt.peoplePerBatch > number of classes. Please decrease this value.')
print(' + opt.peoplePerBatch: ', opt.peoplePerBatch)
print(' + number of classes: ', nClasses)
os.exit(-1)
end
epoch = opt.epochNumber
2015-12-27 21:41:49 +08:00
for _=1,opt.nEpochs do
train()
2016-07-14 01:28:11 +08:00
model = saveModel(model)
2016-03-07 10:15:10 +08:00
if opt.testing then
2016-03-07 08:45:37 +08:00
test()
end
epoch = epoch + 1
end