How to calculate time spent on every layer in CNN with caffe interface?

Q:

I was trying to calculate the time spent on every layer in fast-rcnn network. I found out that caffe cmd interface caffe time can do it. But the fast-rcnn is based on the python code, is there any function in the python interface can help me calculate the time ?

A:

python has profiling tools. You can look at timeit and the cProfile tool.
If you are looking for something more basic, you can use time module to measure time:

import time
t = time.time()
run_rcnn_script()
dt = time.time()-t
print "time spent in run_rcnn_script: ", dt, " sec."

A:

To calculate time spent at each layer

import timeit

t1=timeit.default_timer()
net.forward(start='start_layer_name',end='end_layer_name')
t2=timeit.default_timer()

print 'time is {}'.format(t2-t1)

 

posted on 2017-12-08 16:34  塔上的樹  阅读(298)  评论(0)    收藏  举报