1 #include "caffe2/operators/sigmoid_op.h" 3 #include "caffe2/utils/eigen_utils.h" 14 bool SigmoidGradientFunctor<CPUContext>::Forward(
15 const std::vector<int>& Y_dims,
16 const std::vector<int>& ,
21 const int size = std::accumulate(
22 Y_dims.cbegin(), Y_dims.cend(), 1, std::multiplies<int>());
23 ConstEigenVectorArrayMap<T> dY_arr(dY, size);
24 ConstEigenVectorArrayMap<T> Y_arr(Y, size);
25 EigenVectorArrayMap<T>(dX, size) = dY_arr * Y_arr * (
T(1) - Y_arr);
29 REGISTER_CPU_OPERATOR(
34 SigmoidGradientFunctor<CPUContext>>);
38 class GetSigmoidGradient :
public GradientMakerBase {
39 using GradientMakerBase::GradientMakerBase;
40 std::vector<OperatorDef> GetGradientDefs()
override {
41 return SingleGradientDef(
44 std::vector<std::string>{O(0), GO(0)},
45 std::vector<std::string>{GI(0)});
51 REGISTER_GRADIENT(Sigmoid, GetSigmoidGradient);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...