Created
May 28, 2017 13:05
-
-
Save nitinkgp23/075c449118d480eb36712a069ca3efa5 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
---------------------------------------------------------------------- | |
-- Train a ConvNet on faces. | |
-- | |
-- original: Clement Farabet | |
-- new version by: E. Culurciello | |
-- Mon Oct 14 14:58:50 EDT 2013 | |
---------------------------------------------------------------------- | |
require 'pl' | |
require 'trepl' | |
require 'torch' -- torch | |
require 'image' -- to visualize the dataset | |
require 'nn' -- provides all sorts of trainable modules/layers | |
-- require 'cunn' | |
---------------------------------------------------------------------- | |
print(sys.COLORS.red .. '==> processing options') | |
opt = lapp[[ | |
-r,--learningRate (default 1e-3) learning rate | |
-d,--learningRateDecay (default 1e-7) learning rate decay (in # samples) | |
-w,--weightDecay (default 1e-5) L2 penalty on the weights | |
-m,--momentum (default 0.1) momentum | |
-d,--dropout (default 0.5) dropout amount | |
-b,--batchSize (default 128) batch size | |
-t,--threads (default 8) number of threads | |
-p,--type (default cuda) float or cuda | |
-i,--devid (default 1) device ID (if using CUDA) | |
-s,--size (default small) dataset: small or full or extra | |
-o,--save (default results) save directory | |
--patches (default all) percentage of samples to use for testing' | |
--visualize (default true) visualize dataset | |
]] | |
opt.batchSize=1 | |
-- nb of threads and fixed seed (for repeatable experiments) | |
torch.setnumthreads(opt.threads) | |
torch.manualSeed(1) | |
torch.setdefaulttensortype('torch.FloatTensor') | |
-- type: | |
if opt.type == 'cuda' then | |
print(sys.COLORS.red .. '==> switching to CUDA') | |
require 'cunn' | |
cutorch.setDevice(opt.devid) | |
print(sys.COLORS.red .. '==> using GPU #' .. cutorch.getDevice()) | |
end | |
---------------------------------------------------------------------- | |
print(sys.COLORS.red .. '==> load modules') | |
local data = require 'data' | |
local train = require 'train' | |
local test = require 'test' | |
---------------------------------------------------------------------- | |
print(sys.COLORS.red .. '==> training!') | |
i=0 | |
while true do | |
train(data.trainData) | |
test(data.testData) | |
i=i+1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment