Batch processing mode in Caffe

安稳与你 提交于 2019-12-09 23:16:23

问题


I'd like to use the Caffe library to extract image features but I'm having performance issues. I can only use the CPU mode. I was told Caffe supported batch processing mode, in which the average time required to process one image was much slower.

I'm calling the following method:

const vector<Blob<Dtype>*>& 
Net::Forward(const vector<Blob<Dtype>* > & bottom, Dtype* loss = NULL);

and I'm putting in a vector of size 1, containing a single blob of the following dimensions - (num: 10, channels: 3, width: 227, height: 227). It represents a single image oversampled in the same way as in the official python wrapper.

This works and gives correct results. It is, however, too slow.

Whenever I try to send in a vector containing more than one blob (of the same dimensions), I get the following error:

F0910 16:10:14.848492 15615 blob.cpp:355] Trying to copy blobs of different sizes.
Check failure stack trace:

How do I make Caffe process my images in a batch?


回答1:


If you want to feed larger batches you need the first (and only) blob in bottom to have num>10. Feeding a blob with num=20 is the same as feeding two inputs with oversample=10. You will, of course, have to perform the averaging manually according to the oversampling you are using.

Furthermore, you might want to change the first input dimension in your deploy.prototxt file from 10 to some larger value (depending on your machine's memory capacity)



来源:https://stackoverflow.com/questions/32504394/batch-processing-mode-in-caffe

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