Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

threshold_layer.hpp 1.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  1. #ifndef CAFFE_THRESHOLD_LAYER_HPP_
  2. #define CAFFE_THRESHOLD_LAYER_HPP_
  3. #include <vector>
  4. #include "caffe/blob.hpp"
  5. #include "caffe/layer.hpp"
  6. #include "caffe/proto/caffe.pb.h"
  7. #include "caffe/layers/neuron_layer.hpp"
  8. namespace caffe {
  9. /**
  10. * @brief Tests whether the input exceeds a threshold: outputs 1 for inputs
  11. * above threshold; 0 otherwise.
  12. */
  13. template <typename Dtype>
  14. class ThresholdLayer : public NeuronLayer<Dtype> {
  15. public:
  16. /**
  17. * @param param provides ThresholdParameter threshold_param,
  18. * with ThresholdLayer options:
  19. * - threshold (\b optional, default 0).
  20. * the threshold value @f$ t @f$ to which the input values are compared.
  21. */
  22. explicit ThresholdLayer(const LayerParameter& param)
  23. : NeuronLayer<Dtype>(param) {}
  24. virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
  25. const vector<Blob<Dtype>*>& top);
  26. virtual inline const char* type() const { return "Threshold"; }
  27. protected:
  28. /**
  29. * @param bottom input Blob vector (length 1)
  30. * -# @f$ (N \times C \times H \times W) @f$
  31. * the inputs @f$ x @f$
  32. * @param top output Blob vector (length 1)
  33. * -# @f$ (N \times C \times H \times W) @f$
  34. * the computed outputs @f$
  35. * y = \left\{
  36. * \begin{array}{lr}
  37. * 0 & \mathrm{if} \; x \le t \\
  38. * 1 & \mathrm{if} \; x > t
  39. * \end{array} \right.
  40. * @f$
  41. */
  42. virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
  43. const vector<Blob<Dtype>*>& top);
  44. virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
  45. const vector<Blob<Dtype>*>& top);
  46. /// @brief Not implemented (non-differentiable function)
  47. virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
  48. const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
  49. NOT_IMPLEMENTED;
  50. }
  51. Dtype threshold_;
  52. };
  53. } // namespace caffe
  54. #endif // CAFFE_THRESHOLD_LAYER_HPP_
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...