diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/RNN/.gitignore b/RNN/.gitignore index 8a768dd..3dc20a9 100644 --- a/RNN/.gitignore +++ b/RNN/.gitignore @@ -2,4 +2,4 @@ gen/ runjob-fullVideo.sh log/ trash/ - +.DS_Store diff --git a/RNN/main.lua b/RNN/main.lua index b7dbb98..6e9f5e4 100644 --- a/RNN/main.lua +++ b/RNN/main.lua @@ -45,7 +45,7 @@ cmd:option('-silent', false, 'don`t print anything to stdout') cmd:option('-uniform', 0.1, 'initialize parameters using uniform distribution between -uniform and uniform. -1 means default initialization') cmd:option('-seqCriterion', false, 'use SequencerCriterion or not. Note to use smaller LR') -- recurrent layer -cmd:option('-lstm', true, 'use Long Short Term Memory (nn.LSTM instead of nn.Recurrent)') +cmd:option('-lstm', false, 'use Long Short Term Memory (nn.LSTM instead of nn.Recurrent)') cmd:option('-bn', false, 'use batch normalization. Only supported with --lstm') cmd:option('-gru', false, 'use Gated Recurrent Units (nn.GRU instead of nn.Recurrent)') cmd:option('-numSegment', 3, 'number of segments for each video') @@ -128,6 +128,9 @@ local data = require 'data-ucf101' local train = require 'train' local test = require 'test' +-- initialize bestAcc +bestAcc = 0 + if opt.testOnly then -- Begin testing with trained model test(data.testData, data.testTarget) @@ -137,8 +140,7 @@ end ------------------------------------------------------------ -- Run ------------------------------------------------------------ --- initialize bestAcc -bestAcc = 0 + print(sys.COLORS.red .. '==> training!') for iteration = 1, opt.maxEpoch do diff --git a/RNN/test.lua b/RNN/test.lua index 4f74a1c..a51c141 100644 --- a/RNN/test.lua +++ b/RNN/test.lua @@ -42,11 +42,16 @@ local prob = {} predsFrames = torch.Tensor(opt.batchSize, nClass, opt.rho - opt.numSegment + 1) -- end +local logsoftmax = nn.LogSoftMax() + if opt.cuda == true then inputs = inputs:cuda() targets = targets:cuda() + logsoftmax = logsoftmax:cuda() end + + -- test function function test(testData, testTarget) @@ -162,7 +167,7 @@ function test(testData, testTarget) end preds = model:forward(inputsSegments) - preds:exp() + preds = logsoftmax:forward(preds):exp() end -- discard the redundant predictions and targets @@ -233,7 +238,7 @@ function test(testData, testTarget) torch.save(opt.save .. '/prob.txt', prob,'ascii') if opt.saveModel == true then - if confusion.totalValid * 100 >= 92 then + if confusion.totalValid * 100 >= 94.2 then checkpoints.save(epoch-1, model, optimState, bestModel, confusion.totalValid*100) end end