matcaffe 编译报错

在编译matcaffe时,出现如下报错:

/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_solver(int, mxArray**, int, const mxArray**)’:
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: no matching function for call to ‘remove_if(std::vector<boost::shared_ptr<caffe::Solver<float> > >::iterator, std::vector<boost::shared_ptr<caffe::Solver<float> > >::iterator, delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>)’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: note: candidate is:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from ./include/caffe/blob.hpp:4,
                 from ./include/caffe/caffe.hpp:7,
                 from /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:18:
/usr/include/c++/4.7/bits/stl_algo.h:1166:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: template argument for ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ uses local type ‘delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_net(int, mxArray**, int, const mxArray**)’:
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: no matching function for call to ‘remove_if(std::vector<boost::shared_ptr<caffe::Net<float> > >::iterator, std::vector<boost::shared_ptr<caffe::Net<float> > >::iterator, delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>)’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: note: candidate is:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from ./include/caffe/blob.hpp:4,
                 from ./include/caffe/caffe.hpp:7,
                 from /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:18:
/usr/include/c++/4.7/bits/stl_algo.h:1166:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: template argument for ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ uses local type ‘delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’

Makefile:518: recipe for target 'matlab/+caffe/private/caffe_.mexa64' failed
make: *** [matlab/+caffe/private/caffe_.mexa64] Error 255 

需要在caffe的makefile中加入:

CXXFLAGS += -std=c++11
再重新编译就好了.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
clear all; % TODO: Edit this to point to the folder your caffe mex file is in. % path_to_matcaffe = '/data/jkrause/cs231b/caffe-rc2/matlab/caffe'; path_to_matcaffe = 'C:/Users/DELL/Downloads/caffe-master/windows'; addpath(path_to_matcaffe) % Load up the image im = imread('peppers.png'); % Get some random image regions (format of each row is [x1 y1 x2 y2]) % Note: If you want to change the number of regions you extract features from, % then you need to change the first input_dim in cnn_deploy.prototxt. regions = [ 1 1 100 100; 100 50 400 250; 1 1 512 284; 200 200 230 220 100 100 300 200]; % Convert image from RGB to BGR and single, which caffe requires. im = single(im(:,:,[3 2 1])); % Get the image mean and crop it to the center mean_data = load('ilsvrc_2012_mean.mat'); image_mean = mean_data.image_mean; cnn_input_size = 227; % Input size to the cnn we trained. off = floor((size(image_mean,1) - cnn_input_size)/2)+1; image_mean = image_mean(off:off+cnn_input_size-1, off:off+cnn_input_size-1, :); % Extract each region ims = zeros(cnn_input_size, cnn_input_size, 3, size(regions, 1), 'single'); for i = 1:size(regions, 1) r = regions(i,:); reg = im(r(2):r(4), r(1):r(3), :); % Resize to input CNN size and subtract mean reg = imresize(reg, [cnn_input_size, cnn_input_size], 'bilinear', 'antialiasing', false); reg = reg - image_mean; % Swap dims 1 and 2 to work with caffe ims(:,:,:,i) = permute(reg, [2 1 3]); end % Initialize caffe with our network. % -cnn_deploy.prototxt gives the structure of the network we're using for % extracting features and is how we specify we want fc6 features. % -cnn512.caffemodel is the binary network containing all the learned weights. % -'test' indicates that we're only going to be extracting features and not % training anything init_key = caffe('init', 'cnn_deploy.prototxt', 'cnn512.caffemodel', 'test'); caffe('set_device', 0); % Specify which gpu we want to use. In this case, let's use the first gpu. caffe('set_mode_gpu'); %caffe('set_mode_cpu'); % Use if you want to use a cpu for whatever reason % Run the CNN f = caffe('forward', {ims}); % Convert the features to (num. dims) x (num. regions) feat = single(reshape(f{1}(:), [], size(ims, 4)));
05-22

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值