Caffe
All Classes Namespaces Functions Variables Typedefs
argmax_layer.hpp
1 #ifndef CAFFE_ARGMAX_LAYER_HPP_
2 #define CAFFE_ARGMAX_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 namespace caffe {
11 
23 template <typename Dtype>
24 class ArgMaxLayer : public Layer<Dtype> {
25  public:
38  explicit ArgMaxLayer(const LayerParameter& param)
39  : Layer<Dtype>(param) {}
40  virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
41  const vector<Blob<Dtype>*>& top);
42  virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
43  const vector<Blob<Dtype>*>& top);
44 
45  virtual inline const char* type() const { return "ArgMax"; }
46  virtual inline int ExactNumBottomBlobs() const { return 1; }
47  virtual inline int ExactNumTopBlobs() const { return 1; }
48 
49  protected:
62  virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
63  const vector<Blob<Dtype>*>& top);
65  virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
66  const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
67  NOT_IMPLEMENTED;
68  }
69  bool out_max_val_;
70  size_t top_k_;
71  bool has_axis_;
72  int axis_;
73 };
74 
75 } // namespace caffe
76 
77 #endif // CAFFE_ARGMAX_LAYER_HPP_
caffe::ArgMaxLayer::ExactNumTopBlobs
virtual int ExactNumTopBlobs() const
Returns the exact number of top blobs required by the layer, or -1 if no exact number is required.
Definition: argmax_layer.hpp:47
caffe::ArgMaxLayer::ArgMaxLayer
ArgMaxLayer(const LayerParameter &param)
Definition: argmax_layer.hpp:38
caffe::ArgMaxLayer::Backward_cpu
virtual void Backward_cpu(const vector< Blob< Dtype > * > &top, const vector< bool > &propagate_down, const vector< Blob< Dtype > * > &bottom)
Not implemented (non-differentiable function)
Definition: argmax_layer.hpp:65
caffe::Blob
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers,...
Definition: blob.hpp:24
caffe::ArgMaxLayer::Forward_cpu
virtual void Forward_cpu(const vector< Blob< Dtype > * > &bottom, const vector< Blob< Dtype > * > &top)
Definition: argmax_layer.cpp:55
caffe::Layer
An interface for the units of computation which can be composed into a Net.
Definition: layer.hpp:33
caffe::ArgMaxLayer::ExactNumBottomBlobs
virtual int ExactNumBottomBlobs() const
Returns the exact number of bottom blobs required by the layer, or -1 if no exact number is required.
Definition: argmax_layer.hpp:46
caffe::ArgMaxLayer::LayerSetUp
virtual void LayerSetUp(const vector< Blob< Dtype > * > &bottom, const vector< Blob< Dtype > * > &top)
Does layer-specific setup: your layer should implement this function as well as Reshape.
Definition: argmax_layer.cpp:11
caffe::ArgMaxLayer::type
virtual const char * type() const
Returns the layer type.
Definition: argmax_layer.hpp:45
caffe::ArgMaxLayer::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: argmax_layer.cpp:33
caffe
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
caffe::ArgMaxLayer
Compute the index of the max values for each datum across all dimensions .
Definition: argmax_layer.hpp:24