VGG 16/19 Slow Runtimes

偶尔善良 提交于 2020-01-14 05:58:09

问题


When I try to get an output from the pre-trained VGG 16/19 models using Caffe with Python (both 2.7 and 3.5) it's taking over 15 seconds on the net.forward() step (on my laptop's CPU).

I was wondering if anyone might advise me as to why this could be, as with many other models (i.e. ResNet, AlexNet) I get an output in a split second, this is the only model I've found so far that's performing this poorly.

The code I'm using is as follows:

img = cv2.imread(path + img_name + '.jpg')
img = transform_img(img,224,224) #Resizes image.
net = caffe.Net(model_prototxt,model_trained,caffe.TEST)
transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
transformer.set_transpose('data', (2,0,1))
net.blobs['data'].data[...] = transformer.preprocess('data', img)
start = timer()
out = net.forward()
end = timer()
print('Runtime: ' + "{0:.2f}".format(end-start) + 's')

Sorry for what may be an extremely rookie question, and thanks in advance to anyone who takes the time to answer.


回答1:


VGG-19 is much slower than its predecessors. Remember, the metric for the ILSVRC competition is accuracy (top-1 / top-5), regardless of training time. A model that train in a week and gets 95.2% accuracy beats a model that trains in 2 hours and get 95.1% accuracy.

Computing power continues to approximate Moore's Law, so we have the freedom to develop algorithms that won't be real-time practical for a few more doubling times. What trains in a week now will take less than a day in five years.

In general, an earlier model will train faster, but with less accuracy, than a later model. This holds with AlexNet, GoogleNet v1, GoogleNet v2, ResNet, and VGG. There's a huge drop-off with VGG: the topological innovations that make it more accurate severely slow down the training rate.



来源:https://stackoverflow.com/questions/42941521/vgg-16-19-slow-runtimes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!