Skip to content

Commit

Permalink
adding input noise
Browse files Browse the repository at this point in the history
  • Loading branch information
zhirongw committed Feb 4, 2016
1 parent e26f295 commit 34fe570
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions misc/DataLoaderRaw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ function DataLoaderRaw:getBatch(opt)
local data = {}
data.pixels = inputs
data.targets = targets
if opt.noise > 0 then
data.pixels:add(torch.randn(inputs:size())*opt.noise)
end
--data.targets:add(torch.randn(targets:size())*0.01)
if opt.gpu >= 0 then
data.pixels = data.pixels:cuda()
data.targets = data.targets:cuda()
Expand Down
8 changes: 5 additions & 3 deletions train.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ cmd:option('-drop_prob_pm', 0.5, 'strength of dropout in the Pixel Model')
cmd:option('-mult_in', true, 'An extension of the LSTM architecture')
cmd:option('-loss_policy', 'exp', 'loss decay policy for spatial patch') -- exp for exponential decay, and linear for linear decay
cmd:option('-loss_decay', 0.9, 'loss decay rate for spatial patch')
cmd:option('-noise', 0, 'input perturbation by adding noise')

-- Optimization: for the Pixel Model
cmd:option('-optim','rmsprop','what update to use? rmsprop|sgd|sgdmom|adagrad|adam')
cmd:option('-learning_rate',1e-4,'learning rate')
Expand All @@ -54,7 +56,7 @@ cmd:option('-optim_epsilon',1e-8,'epsilon that goes into denominator for smoothi

-- Evaluation/Checkpointing
cmd:option('-save_checkpoint_every', 2000, 'how often to save a model checkpoint?')
cmd:option('-checkpoint_path', 'models', 'folder to save checkpoints into (empty = this folder)')
cmd:option('-checkpoint_path', '~/pixel/models', 'folder to save checkpoints into (empty = this folder)')
cmd:option('-losses_log_every', 25, 'How often do we snapshot losses, for inclusion in the progress dump? (0 = disable)')

-- misc
Expand Down Expand Up @@ -181,7 +183,7 @@ local function eval_split(n)
-- fetch a batch of data
local data = loader:getBatch{batch_size = opt.batch_size, num_neighbors = opt.num_neighbors,
patch_size = opt.patch_size, gpu = opt.gpuid, split = 'val',
border = opt.border_init}
border = opt.border_init, noise = opt.noise}

-- forward the model to get loss
local gmms = protos.pm:forward(data.pixels)
Expand Down Expand Up @@ -210,7 +212,7 @@ local function lossFun()
--local timer = torch.Timer()
local data = loader:getBatch{batch_size = opt.batch_size, num_neighbors = opt.num_neighbors,
patch_size = opt.patch_size, gpu = opt.gpuid, split = 'train',
border = opt.border_init}
border = opt.border_init, noise = opt.noise}

-- forward the pixel model
local gmms = protos.pm:forward(data.pixels)
Expand Down

0 comments on commit 34fe570

Please sign in to comment.