building errors
OS: Ubuntu 17.04
Thanks for any help :)
Compilation worked (after commenting out add_subdirectory line for examples), but running into errors with building:
[ 14%] Building CXX object src/caffe/CMakeFiles/caffe.dir/layers/concat_layer.cpp.o [ 16%] Building CXX object src/caffe/CMakeFiles/caffe.dir/layers/contrastive_loss_layer.cpp.o /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp: In instantiation of ‘void caffe::ContrastiveLossLayer<Dtype>::Forward_cpu(const std::vector<caffe::Blob<Dtype>>&, const std::vector<caffe::Blob<Dtype>>&) [with Dtype = float]’: /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:118:1: required from here /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:56:30: error: no matching function for call to ‘max(float, double)’ Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), 0.0); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/6/algorithm:61:0, from /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:1: /usr/include/c++/6/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/6/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:56:30: note: deduced conflicting types for parameter ‘const Tp’ (‘float’ and ‘double’) Dtype dist = std::max(margin - sqrt(dist_sq.cpu_data()[i]), 0.0); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/6/algorithm:61:0, from /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:1: /usr/include/c++/6/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/6/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:56:30: note: deduced conflicting types for parameter ‘const Tp’ (‘float’ and ‘double’) Dtype dist = std::max(margin - sqrt(dist_sq.cpu_data()[i]), 0.0); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/6/algorithm:62:0, from /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:1: /usr/include/c++/6/bits/stl_algo.h:3459:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/6/bits/stl_algo.h:3459:5: note: template argument deduction/substitution failed: /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:56:30: note: mismatched types ‘std::initializer_list<Tp>’ and ‘float’ Dtype dist = std::max(margin - sqrt(dist_sq.cpu_data()[i]), 0.0); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/6/algorithm:62:0, from /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:1: /usr/include/c++/6/bits/stl_algo.h:3465:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/6/bits/stl_algo.h:3465:5: note: template argument deduction/substitution failed: /home/daniel/Desktop/cats/hed/src/caffe/layers/contrastive_loss_layer.cpp:56:30: note: mismatched types ‘std::initializer_list<Tp>’ and ‘float’ Dtype dist = std::max(margin - sqrt(dist_sq.cpu_data()[i]), 0.0); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/caffe/CMakeFiles/caffe.dir/build.make:398: recipe for target 'src/caffe/CMakeFiles/caffe.dir/layers/contrastive_loss_layer.cpp.o' failed make[2]: *** [src/caffe/CMakeFiles/caffe.dir/layers/contrastive_loss_layer.cpp.o] Error 1 CMakeFiles/Makefile2:272: recipe for target 'src/caffe/CMakeFiles/caffe.dir/all' failed make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2
Have the same issue!
Have you solved this ? I met the same error
If anyone still wondering, just go into the file and add float() to the variables should get rid of this.
Replace line 56 by this one :
Dtype dist = std::max(margin - (float)sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));
Dtype dist = std::max(margin - (double)sqrt(dist_sq_.cpu_data()[i]), 0.0);