Caffe
euclidean_loss_layer.hpp
1 #ifndef CAFFE_EUCLIDEAN_LOSS_LAYER_HPP_
2 #define CAFFE_EUCLIDEAN_LOSS_LAYER_HPP_
3 
4 #include <vector>
5 
6 #include "caffe/blob.hpp"
7 #include "caffe/layer.hpp"
8 #include "caffe/proto/caffe.pb.h"
9 
10 #include "caffe/layers/loss_layer.hpp"
11 
12 namespace caffe {
13 
40 template <typename Dtype>
41 class EuclideanLossLayer : public LossLayer<Dtype> {
42  public:
43  explicit EuclideanLossLayer(const LayerParameter& param)
44  : LossLayer<Dtype>(param), diff_() {}
45  virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
46  const vector<Blob<Dtype>*>& top);
47 
48  virtual inline const char* type() const { return "EuclideanLoss"; }
53  virtual inline bool AllowForceBackward(const int bottom_index) const {
54  return true;
55  }
56 
57  protected:
59  virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
60  const vector<Blob<Dtype>*>& top);
61  virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
62  const vector<Blob<Dtype>*>& top);
63 
97  virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
98  const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
99  virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
100  const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
101 
102  Blob<Dtype> diff_;
103 };
104 
105 } // namespace caffe
106 
107 #endif // CAFFE_EUCLIDEAN_LOSS_LAYER_HPP_
virtual bool AllowForceBackward(const int bottom_index) const
Definition: euclidean_loss_layer.hpp:53
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
virtual void Reshape(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Adjust the shapes of top blobs and internal buffers to accommodate the shapes of the bottom blobs...
Definition: euclidean_loss_layer.cpp:9
virtual void Backward_cpu(const vector< Blob< Dtype > *> &top, const vector< bool > &propagate_down, const vector< Blob< Dtype > *> &bottom)
Computes the Euclidean error gradient w.r.t. the inputs.
Definition: euclidean_loss_layer.cpp:32
virtual void Forward_cpu(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Computes the Euclidean (L2) loss for real-valued regression tasks.
Definition: euclidean_loss_layer.cpp:18
virtual void Forward_gpu(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Using the GPU device, compute the layer output. Fall back to Forward_cpu() if unavailable.
virtual const char * type() const
Returns the layer type.
Definition: euclidean_loss_layer.hpp:48
An interface for Layers that take two Blobs as input – usually (1) predictions and (2) ground-truth ...
Definition: loss_layer.hpp:23
virtual void Backward_gpu(const vector< Blob< Dtype > *> &top, const vector< bool > &propagate_down, const vector< Blob< Dtype > *> &bottom)
Using the GPU device, compute the gradients for any parameters and for the bottom blobs if propagate_...
Computes the Euclidean (L2) loss for real-valued regression tasks.
Definition: euclidean_loss_layer.hpp:41
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers...
Definition: blob.hpp:24