1 #include "caffe2/sgd/clip_tensor_op.h" 5 REGISTER_CPU_OPERATOR(ClipTensorByScaling, ClipTensorByScalingOp<CPUContext>);
6 OPERATOR_SCHEMA(ClipTensorByScaling)
9 .AllowInplace({{0, 0}})
11 Clips the input tensor by scaling based on the input value and the threshold. 12 The value is usually the (pre-computed) norm of the tensor. If the value is 13 larger than the threshold, scaling would be performed in this way: 15 tensor *= (threshold / value). 17 An optional input called additional_threshold can be provided which 18 will scale the original threshold before it is used. That is, 19 the final threshold will become threshold * additional_threshold. 20 This op could be used for gradient clipping. 22 .Input(0, "input_tensor",
"Tensor of floats to be clipped.")
23 .Input(1,
"val",
"Value to be compared against the threshold")
26 "additional_threshold",
27 "An optional additonal threshold to scale the orignal threshold")
28 .Arg(
"threshold",
"Threshold to determine whether to scale down the tensor")
32 "Tensor of floats, which is the same size as the input tensor, " 33 "representing the clipped tensor.");
35 SHOULD_NOT_DO_GRADIENT(ClipTensorByScaling);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...