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  CosineEmbeddingCriterionOp(const OperatorDef& def, Workspace* ws)
14  : Operator<Context>(def, ws),
15  OP_SINGLE_ARG(float, "margin", margin_, 0.0) {}
16  USE_OPERATOR_CONTEXT_FUNCTIONS;
17 
18  bool RunOnDevice() override;
19 
20  protected:
21  float margin_;
22 };
23 
24 template <class Context>
25 class CosineEmbeddingCriterionGradientOp final : public Operator<Context> {
26  public:
27  CosineEmbeddingCriterionGradientOp(const OperatorDef& def, Workspace* ws)
28  : Operator<Context>(def, ws),
29  OP_SINGLE_ARG(float, "margin", margin_, 0.0) {}
30  USE_OPERATOR_CONTEXT_FUNCTIONS;
31 
32  bool RunOnDevice() override;
33 
34  protected:
35  float margin_;
36 };
37 
38 } // namespace caffe2
39 
40 #endif // CAFFE2_OPERATORS_COSINE_EMBEDDING_CRITERION_OP_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:47
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...