Caffe2 - C++ API
A deep learning, cross platform ML framework
cosine_embedding_criterion_op.h
1 
17 #ifndef CAFFE2_OPERATORS_COSINE_EMBEDDING_CRITERION_OP_H_
18 #define CAFFE2_OPERATORS_COSINE_EMBEDDING_CRITERION_OP_H_
19 
20 #include "caffe2/core/context.h"
21 #include "caffe2/core/logging.h"
22 #include "caffe2/core/operator.h"
23 
24 namespace caffe2 {
25 
26 template <class Context>
27 class CosineEmbeddingCriterionOp final : public Operator<Context> {
28  public:
29  CosineEmbeddingCriterionOp(const OperatorDef& def, Workspace* ws)
30  : Operator<Context>(def, ws),
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 template <class Context>
41 class CosineEmbeddingCriterionGradientOp final : public Operator<Context> {
42  public:
43  CosineEmbeddingCriterionGradientOp(const OperatorDef& def, Workspace* ws)
44  : Operator<Context>(def, ws),
45  OP_SINGLE_ARG(float, "margin", margin_, 0.0) {}
46  USE_OPERATOR_CONTEXT_FUNCTIONS;
47 
48  bool RunOnDevice() override;
49 
50  protected:
51  float margin_;
52 };
53 
54 } // namespace caffe2
55 
56 #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:63
Copyright (c) 2016-present, Facebook, Inc.