oneflow.clamp_max¶
-
oneflow.clamp_max()¶ Clamp all elements in
inputwhich are greater thanmaxtomaxand return a resulting tensor:\[y_i = \min(max, x_i)\]If
inputis of type FloatTensor or DoubleTensor, argsmaxmust be real numbers, otherwise they should be integers.- Parameters
For example:
>>> import oneflow as flow >>> input = flow.Tensor([0.2, 0.6, -1.5, -0.3]) >>> output = flow.clamp_max(input, max=-0.5) >>> output tensor([-0.5000, -0.5000, -1.5000, -0.5000], dtype=oneflow.float32) >>> input = flow.Tensor([0.2, 0.6, -1.5, -0.3]) >>> output = flow.clamp_max(input, max=-2) >>> output tensor([-2., -2., -2., -2.], dtype=oneflow.float32) >>> input = flow.Tensor([0.2, 0.6, -1.5, -0.3]) >>> output = flow.clamp_max(input, max=1) >>> output tensor([ 0.2000, 0.6000, -1.5000, -0.3000], dtype=oneflow.float32)