Rate this Page
★ ★ ★ ★ ★

torch.clamp_min#

torch.clamp_min(input, min, *, out=None) → Tensor#

Clamps each element of input to be at least min. Equivalent to torch.clamp() with only min specified. If min is a tensor, input and min are broadcast to a common shape.

Parameters:
  • input (Tensor) – the input tensor.

  • min (Number or Tensor) – lower bound for each element.

Keyword Arguments:

out (Tensor, optional) – the output tensor.

Examples:

>>> a = torch.tensor([-1.0, 0.5, 2.0])
>>> torch.clamp_min(a, 0.0)
tensor([0.0000, 0.5000, 2.0000])
>>> torch.clamp_min(a, torch.tensor([[0.0], [1.0]]))
tensor([[0.0000, 0.5000, 2.0000],
        [1.0000, 1.0000, 2.0000]])