1 #include "caffe2/operators/tanh_op.h" 3 #include "caffe2/utils/eigen_utils.h" 7 #ifdef CAFFE2_USE_ACCELERATE 10 bool TanhFunctor<CPUContext>::operator()<
float>(
18 #endif // CAFFE2_USE_ACCELERATE 20 REGISTER_CPU_OPERATOR(
25 TanhFunctor<CPUContext>>);
30 .AllowInplace({{0, 0}})
31 .IdenticalTypeAndShape()
33 Calculates the hyperbolic tangent of the given input tensor element-wise. This 34 operation can be done in an in-place fashion too, by providing the same input 39 - https://github.com/pytorch/pytorch/blob/master/caffe2/operators/tanh_op.cc 44 <summary> <b>Example</b> </summary> 50 workspace.ResetWorkspace() 52 op = core.CreateOperator( 58 workspace.FeedBlob("X", np.random.randn(3, 3).astype(np.float32)) 59 print("X:\n", workspace.FetchBlob("X"), "\n") 61 workspace.RunOperatorOnce(op) 62 print("X:\n", workspace.FetchBlob("X")) 71 [[ 2.032603 -2.3556721 -0.14955314] 72 [ 0.39309832 -1.1020128 -0.92951244] 73 [-0.62815386 0.21342885 1.4002231 ]] 76 [[ 0.9662601 -0.982175 -0.14844811] 77 [ 0.3740282 -0.8012209 -0.73036647] 78 [-0.55677974 0.21024609 0.8853999 ]] 85 .Input(0, "input",
"1-D input tensor")
89 "The hyperbolic tangent values of the input tensor, computed " 93 OPERATOR_SCHEMA(TanhGradient).NumInputs(2).NumOutputs(1).AllowInplace({{1, 0}});
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...