mariolew / caffe-unpooling

Caffe with unpooling layers and example usage.
Other
18 stars 11 forks source link

I'm having a problem with constrative_loss file #9

Open AlexGbenimachor opened 6 years ago

AlexGbenimachor commented 6 years ago

Good day, Please, I'm having a problem setting up the caffe, because I get an error from the constrative_loss file, is like their is something wrong with file and how do I fix. thank you and I wait in anticipation for your reply. Best Regards Alex Gbenimachor

Below is the Error in the code.

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]’: src/caffe/layers/contrastive_loss_layer.cpp:116:1: required from here src/caffe/layers/contrastive_loss_layer.cpp:54: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 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:
src/caffe/layers/contrastive_loss_layer.cpp:54: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 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:
src/caffe/layers/contrastive_loss_layer.cpp:54: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 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:
src/caffe/layers/contrastive_loss_layer.cpp:54: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 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:
src/caffe/layers/contrastive_loss_layer.cpp:54:30: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘float’
         Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), 0.0);
                      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Makefile:552: recipe for target '.build_release/src/caffe/layers/contrastive_loss_layer.o' failed
make: *** [.build_release/src/caffe/layers/contrastive_loss_layer.o] Error 1
AlexGbenimachor commented 6 years ago

I had to downgrade my gcc and g++ to run the code but i got a protobuf error, it their way to go round this. thank you