17 #include "sigmoid_cross_entropy_loss_op.h" 21 REGISTER_CPU_OPERATOR(
22 SigmoidCrossEntropyLoss,
23 SigmoidCrossEntropyLossOp<float, CPUContext>);
24 REGISTER_CPU_OPERATOR(
25 SigmoidCrossEntropyLossGradient,
26 SigmoidCrossEntropyLossGradientOp<float, CPUContext>);
28 OPERATOR_SCHEMA(SigmoidCrossEntropyLoss)
32 Compute sigmoid activations followed by averaged binary cross entropy loss. The 33 target values may be in {-1, 0, 1}, where -1 indicates that the corresponding 34 sample should be ignored and {0, 1} correspond to the binary classes 0 and 1. By 35 default the loss is divided by the number of targets > -1 and then multiplied by 36 the `scale` op argument. The divisive normalization may be disable by setting 37 the op argument `normalize` to 0 (the multiplication by `scale` still takes 40 This op fuses sigmoid and cross entropy for numerical stability in both forward 41 and gradient computation. 45 "(float) default 1.0; multiply the loss by this scale factor.")
48 "(int) default 1; if true, divide the loss by the number of targets > " 53 "Tensor of predicted logits (shape must be at least 1D).")
57 "Tensor of targets of type int and same shape as logits X.")
63 OPERATOR_SCHEMA(SigmoidCrossEntropyLossGradient)
69 "See SigmoidCrossEntropyLoss.")
73 "See SigmoidCrossEntropyLoss.")
77 "Gradient of forward output 0 (loss).")
81 "Gradient of forward input 0 (X).");
84 using GradientMakerBase::GradientMakerBase;
85 vector<OperatorDef> GetGradientDefs()
override {
87 "SigmoidCrossEntropyLossGradient",
89 vector<string>{I(0), I(1), GO(0)},
90 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 ...