17 #include "smooth_l1_loss_op.h" 21 REGISTER_CPU_OPERATOR(SmoothL1Loss, SmoothL1LossOp<float, CPUContext>);
22 REGISTER_CPU_OPERATOR(
24 SmoothL1LossGradientOp<float, CPUContext>);
26 OPERATOR_SCHEMA(SmoothL1Loss)
30 Smooth L1 Loss is a minor variation of Huber loss in which the point of 31 transition between L2 loss and L1 loss is adjustable by a hyper-parameter beta: 33 SmoothL1(x) = 0.5 * x^2 / beta if |x| < beta 34 |x| - 0.5 * beta otherwise. 36 SmoothL1 is used in Fast R-CNN and decendants as the loss function for bounding 39 The loss computed by this op has a flexible form: 41 scale / N * sum_i alpha_out[i] * SmoothL1(alpha_in[i] * (y_hat[i] - y[i])). 43 The weights alpha_in and alpha_out are called the "inside" and "outside" 44 weights, respectively. The inside weights are typically set to either 0 or 1 to 45 implement ignoring (when 0) certain samples. The outside weights can be used 46 to implement a per-sample loss weight. The overall loss is scaled by scale / N, 47 where N is the number of batch elements in the input predictions. 51 "(float) default 1.0; L2 to L1 transition point.")
54 "(float) default 1.0; multiply the loss by this scale factor.")
58 "Tensor of predictions (at least 1D).")
62 "Tensor of labels with the same shape as Y_hat.")
66 "Tensor of inside weights with the same shape as Y.")
70 "Tensor of outside weights with the same shape as Y.")
76 OPERATOR_SCHEMA(SmoothL1LossGradient)
98 "Gradient of forward output 0 (loss).")
102 "Gradient of forward input 0 (Y_hat).");
105 using GradientMakerBase::GradientMakerBase;
106 vector<OperatorDef> GetGradientDefs()
override {
108 "SmoothL1LossGradient",
110 vector<string>{I(0), I(1), I(2), I(3), GO(0)},
111 vector<string>{GI(0)});
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
static vector< OperatorDef > SingleGradientDef(const Args &...args)
a helper function to allow one to create one single operator def, which is usually the case for many ...