Caffe中的批处理模式 [英] Batch processing mode in Caffe

查看:220
本文介绍了Caffe中的批处理模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Caffe库来提取图片功能,但我遇到了性能问题。我只能使用CPU模式。我被告知Caffe支持批处理模式,其中处理一个图像所需的平均时间慢得多。

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.

我调用以下方法:

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

并且我放入一个大小为1的向量,包含以下维度的单个blob: (num:10,channels:3,width:227,height:227)。它代表一个单一的图像,过滤器的方式和官方的python包装器一样。

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.

每当我尝试发送一个包含多个blob(相同的维度)的向量时,我得到以下错误: / p>

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]尝试复制不同大小的Blob。

失败堆栈跟踪:

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

如何使Caffe批量处理我的图像?

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

推荐答案

如果你想喂大批量,你需要在 bottom 中的第一个$ c> num> 10 。使用 num = 20 进给Blob与使用 oversample = 10 喂入两个输入相同。当然,您必须根据您使用的 oversampling 手动执行平均。

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.

此外,您可能需要将 deploy.prototxt 文件中的第一个输入维度从10更改为更大的值(取决于计算机的内存容量)

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)

这篇关于Caffe中的批处理模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆