oneflow.clamp_min

oneflow.clamp_min()

Clamp all elements in input which are less than min to min and return a resulting tensor:

\[y_i = \max(min, x_i)\]

If input is of type FloatTensor or DoubleTensor, args min must be real numbers, otherwise they should be integers.

Parameters
  • input (Tensor) – the input tensor.

  • min (Number) – lower-bound of the range to be clamped to.

  • out (Tensor, optional) – the output tensor.

For example:

>>> import oneflow as flow
>>> input = flow.Tensor([0.2, 0.6, -1.5, -0.3])
>>> output = flow.clamp_min(input, min=-0.5)
>>> output
tensor([ 0.2000,  0.6000, -0.5000, -0.3000], dtype=oneflow.float32)

>>> input = flow.Tensor([0.2, 0.6, -1.5, -0.3])
>>> output = flow.clamp_min(input, min=-2)
>>> output
tensor([ 0.2000,  0.6000, -1.5000, -0.3000], dtype=oneflow.float32)

>>> input = flow.Tensor([0.2, 0.6, -1.5, -0.3])
>>> output = flow.clamp_min(input, min=1)
>>> output
tensor([1., 1., 1., 1.], dtype=oneflow.float32)