s9xie / hed

code for Holistically-Nested Edge Detection
Other
1.8k stars 530 forks source link

building errors #43

Open danielnjoo opened 7 years ago

danielnjoo commented 7 years ago

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::Forward_cpu(const std::vector<caffe::Blob>&, const std::vector<caffe::Blob>&) [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(distsq.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
sfeng15 commented 6 years ago

Have the same issue!

KelvinZhang95 commented 6 years ago

Have you solved this ? I met the same error

pc4653 commented 6 years ago

If anyone still wondering, just go into the file and add float() to the variables should get rid of this.

empty16 commented 6 years ago

Replace line 56 by this one : Dtype dist = std::max(margin - (float)sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));

frankie-yanfeng commented 5 years ago

Dtype dist = std::max(margin - (double)sqrt(distsq.cpu_data()[i]), 0.0);