Caffe2 - C++ API
A deep learning, cross platform ML framework
cosine_embedding_criterion_op.h
1 #ifndef CAFFE2_OPERATORS_COSINE_EMBEDDING_CRITERION_OP_H_
2 #define CAFFE2_OPERATORS_COSINE_EMBEDDING_CRITERION_OP_H_
3 
4 #include "caffe2/core/context.h"
5 #include "caffe2/core/logging.h"
6 #include "caffe2/core/operator.h"
7 
8 namespace caffe2 {
9 
10 template <class Context>
11 class CosineEmbeddingCriterionOp final : public Operator<Context> {
12  public:
13  template <class... Args>
14  explicit CosineEmbeddingCriterionOp(Args&&... args)
15  : Operator<Context>(std::forward<Args>(args)...),
16  OP_SINGLE_ARG(float, "margin", margin_, 0.0) {}
17  USE_OPERATOR_CONTEXT_FUNCTIONS;
18 
19  bool RunOnDevice() override;
20 
21  protected:
22  float margin_;
23 };
24 
25 template <class Context>
26 class CosineEmbeddingCriterionGradientOp final : public Operator<Context> {
27  public:
28  template <class... Args>
29  explicit CosineEmbeddingCriterionGradientOp(Args&&... args)
30  : Operator<Context>(std::forward<Args>(args)...),
31  OP_SINGLE_ARG(float, "margin", margin_, 0.0) {}
32  USE_OPERATOR_CONTEXT_FUNCTIONS;
33 
34  bool RunOnDevice() override;
35 
36  protected:
37  float margin_;
38 };
39 
40 } // namespace caffe2
41 
42 #endif // CAFFE2_OPERATORS_COSINE_EMBEDDING_CRITERION_OP_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13