Torch: Model fast when learning/testing, slow when using it -
i have issue using learned model torch.
i followed howto http://code.cogbits.com/wiki/doku.php?id=tutorial_supervised train model. fine, model trained , have corrects results when use model. it's slow !
the testing part training this:
model:evaluate() -- test on test data print('==> testing on test set:') t = 1,testdata:size() -- disp progress xlua.progress(t, testdata:size()) -- new sample local input = testdata.data[t] if opt.type == 'double' input = input:double() elseif opt.type == 'cuda' input = input:cuda() end local target = testdata.labels[t] -- test sample local pred = model:forward(input) confusion:add(pred, target) end -- timing time = sys.clock() - time time = time / testdata:size() print("\n==> time test 1 sample = " .. (time*1000) .. 'ms')
i have following speed recorded during testing:
==> time test 1 sample = 12.419194088996ms
(of course vary, it's ~12ms).
i want use learned model on others images, did in simple , new script:
(... requires) torch.setnumthreads(8) torch.setdefaulttensortype('torch.floattensor') model = torch.load('results/model.net') model:evaluate() (... image loading, resizing , normalization) local time = sys.clock() local result_info = model:forward(cropped_image:double()) print("==> time test 1 frame = " .. (sys.clock() - time) * 1000 .. "ms")
the time spent bigger, have following output: ==> time test 1 frame = 212.7647127424ms
i tested more 1 image, resizing , normalization outside clock's measurements, , have > 200ms / image.
i don't understand i'm doing wrong , why code slower during training/testing.
thanks !
Comments
Post a Comment