Caffe
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_
An interface for the units of computation which can be composed into a Net.
Definition: layer.hpp:33
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
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
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
Compute the index of the max values for each datum across all dimensions .
Definition: argmax_layer.hpp:24
virtual const char * type() const
Returns the layer type.
Definition: argmax_layer.hpp:45
virtual void Forward_cpu(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Definition: argmax_layer.cpp:55
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
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
ArgMaxLayer(const LayerParameter &param)
Definition: argmax_layer.hpp:38
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
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers...
Definition: blob.hpp:24