Caffe2 - C++ API
A deep learning, cross platform ML framework
loss_op.h
1 
17 #ifndef CAFFE2_OPERATORS_LOSS_OP_H_
18 #define CAFFE2_OPERATORS_LOSS_OP_H_
19 
20 #include "caffe2/core/context.h"
21 #include "caffe2/core/logging.h"
22 #include "caffe2/core/operator.h"
23 #include "caffe2/operators/reduction_ops.h"
24 #include "caffe2/operators/utility_ops.h"
25 #include "caffe2/utils/math.h"
26 
27 namespace caffe2 {
28 
29 // AveragedLoss takes in the input and produces the output loss value as
30 // the average of the input.
31 template <typename T, class Context>
32 class AveragedLoss final : public SumElementsOp<T, Context> {
33  public:
34  AveragedLoss(const OperatorDef& operator_def, Workspace* ws)
35  : SumElementsOp<T, Context>(operator_def, ws, true) {}
36  ~AveragedLoss() {}
37 };
38 
39 template <typename T, class Context>
40 class AveragedLossGradient final : public SumElementsGradientOp<T, Context> {
41  public:
42  AveragedLossGradient(const OperatorDef& operator_def, Workspace* ws)
43  : SumElementsGradientOp<T, Context>(operator_def, ws, true) {}
45 };
46 
47 } // namespace caffe2
48 
49 #endif // CAFFE2_OPERATORS_LOSS_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.