euclidean_loss_layer.hpp
#ifndef CAFFE_EUCLIDEAN_LOSS_LAYER_HPP_
#define CAFFE_EUCLIDEAN_LOSS_LAYER_HPP_
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/layers/loss_layer.hpp"
namespace caffe {
template <typename Dtype>
class EuclideanLossLayer : public LossLayer<Dtype> {
public:
explicit EuclideanLossLayer(const LayerParameter& param)
: LossLayer<Dtype>(param), diff_() {}
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual inline const char* type() const { return "EuclideanLoss"; }
virtual inline bool AllowForceBackward(const int bottom_index) const {
return true;
}
protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
Blob<Dtype> diff_;
};
} // namespace caffe
#endif // CAFFE_EUCLIDEAN_LOSS_LAYER_HPP_
caffe::EuclideanLossLayer::Backward_gpu
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_...
caffe::EuclideanLossLayer::Backward_cpu
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
caffe::EuclideanLossLayer::type
virtual const char * type() const
Returns the layer type.
Definition: euclidean_loss_layer.hpp:48
caffe::EuclideanLossLayer::Forward_cpu
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
caffe::EuclideanLossLayer
Computes the Euclidean (L2) loss for real-valued regression tasks.
Definition: euclidean_loss_layer.hpp:41
caffe::EuclideanLossLayer::Forward_gpu
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.
caffe::EuclideanLossLayer::Reshape
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
caffe::Blob
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers,...
Definition: blob.hpp:24
caffe::LossLayer
An interface for Layers that take two Blobs as input – usually (1) predictions and (2) ground-truth l...
Definition: loss_layer.hpp:23
caffe
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
caffe::EuclideanLossLayer::AllowForceBackward
virtual bool AllowForceBackward(const int bottom_index) const
Definition: euclidean_loss_layer.hpp:53