I use the time.clock to evaluate the forward time, code like:
start_t = clock()
output = net(Variable(input))
forward_time += (clock() - start_t) * 1000
I found it’s not very stable when test time.
The forward time of
start_t = clock()
output = net(Variable(input))
forward_time += (clock() - start_t) * 1000
output = output.data[0][0].cpu().numpy()
is faster than the time of
start_t = clock()
output = net(Variable(input))
forward_time += (clock() - start_t) * 1000
out = output.data[0][0]
Although I just put the clock() before and after “out = net(xxx)”, the other code after time testing will also effect the forward time.