Caffe
dropout_layer.hpp
1 #ifndef CAFFE_DROPOUT_LAYER_HPP_
2 #define CAFFE_DROPOUT_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/neuron_layer.hpp"
11 
12 namespace caffe {
13 
25 template <typename Dtype>
26 class DropoutLayer : public NeuronLayer<Dtype> {
27  public:
34  explicit DropoutLayer(const LayerParameter& param)
35  : NeuronLayer<Dtype>(param) {}
36  virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
37  const vector<Blob<Dtype>*>& top);
38  virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
39  const vector<Blob<Dtype>*>& top);
40 
41  virtual inline const char* type() const { return "Dropout"; }
42 
43  protected:
60  virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
61  const vector<Blob<Dtype>*>& top);
62  virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
63  const vector<Blob<Dtype>*>& top);
64  virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
65  const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
66  virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
67  const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
68 
72  Dtype threshold_;
74  Dtype scale_;
75  unsigned int uint_thres_;
76 };
77 
78 } // namespace caffe
79 
80 #endif // CAFFE_DROPOUT_LAYER_HPP_
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_...
Blob< unsigned int > rand_vec_
when divided by UINT_MAX, the randomly generated values
Definition: dropout_layer.hpp:70
Dtype scale_
the scale for undropped inputs at train time
Definition: dropout_layer.hpp:74
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: dropout_layer.cpp:22
virtual void Forward_cpu(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Definition: dropout_layer.cpp:31
DropoutLayer(const LayerParameter &param)
Definition: dropout_layer.hpp:34
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.
An interface for layers that take one blob as input ( ) and produce one equally-sized blob as output ...
Definition: neuron_layer.hpp:19
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: dropout_layer.cpp:11
virtual const char * type() const
Returns the layer type.
Definition: dropout_layer.hpp:41
During training only, sets a random portion of to 0, adjusting the rest of the vector magnitude acco...
Definition: dropout_layer.hpp:26
Dtype threshold_
the probability of dropping any input
Definition: dropout_layer.hpp:72
virtual void Backward_cpu(const vector< Blob< Dtype > *> &top, const vector< bool > &propagate_down, const vector< Blob< Dtype > *> &bottom)
Using the CPU device, compute the gradients for any parameters and for the bottom blobs if propagate_...
Definition: dropout_layer.cpp:49
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers...
Definition: blob.hpp:24