torch.clamp_max#
- torch.clamp_max(input, max, *, out=None) Tensor#
Clamps each element of
inputto be at mostmax. Equivalent totorch.clamp()with onlymaxspecified. Ifmaxis a tensor,inputandmaxare broadcast to a common shape.- Parameters:
- Keyword Arguments:
out (Tensor, optional) – the output tensor.
Examples:
>>> a = torch.tensor([-1.0, 0.5, 2.0]) >>> torch.clamp_max(a, 1.0) tensor([-1.0000, 0.5000, 1.0000]) >>> torch.clamp_max(a, torch.tensor([[0.0], [1.0]])) tensor([[-1.0000, 0.0000, 0.0000], [-1.0000, 0.5000, 1.0000]])