forked from xialuxi/arcface-caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cosin_add_m_layer.hpp
50 lines (38 loc) · 1.26 KB
/
cosin_add_m_layer.hpp
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
#ifndef CAFFE_COSIN_ADD_M_LAYER_HPP_
#define CAFFE_COSIN_ADD_M_LAYER_HPP_
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
namespace caffe {
template <typename Dtype>
class CosinAddmLayer : public Layer<Dtype> {
public:
explicit CosinAddmLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual inline const char* type() const { return "CosinAddm"; }
virtual inline int MinNumBottomBlobs() const { return 2; }
protected:
virtual void Forward_cpu(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);
Dtype m_;
Dtype sin_m;
Dtype cos_m;
Dtype threshold;
Blob<Dtype> cos_theta;
Blob<Dtype> top_flag;
bool transform_test_;
int count_num;
int count_num_back;
};
} // namespace caffe
#endif // CAFFE_COSIN_ADD_M_LAYER_HPP_