Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

Deep CV

[Pytorch] torch.clamp 본문

딥러닝/PyTorch

[Pytorch] torch.clamp

Present_Kim 2021. 10. 18. 03:26
torch.clamp(input, min=None, max=None, *, out=None)

min과 Max를 정하고, min보다 작으면 min으로 Max 보다 크면 Max로 제한 합니다.

Parameters

  • input (Tensor) – the input tensor.
  • min (Number or Tensor, optional) – lower-bound of the range to be clamped to
  • max (Number or Tensor, optional) – upper-bound of the range to be clamped to

Example

>>> a = torch.randn(4)
>>> a
tensor([-1.7120,  0.1734, -0.0478, -0.0922])
>>> torch.clamp(a, min=-0.5, max=0.5)
tensor([-0.5000,  0.1734, -0.0478, -0.0922])