딥러닝/PyTorch

[Pytorch] torch.linspace

Present_Kim 2021. 10. 18. 00:01
torch.linspace(start, end, steps, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False)

start와 end를 사이가 균일하게 나눠진 steps 크기의 tensor를 생성합니다. 

Parameters

  • start (float) – the starting value for the set of points
  • end (float) – the ending value for the set of points
  • steps (int) – size of the constructed tensor

Example

>>> torch.linspace(3, 10, steps=5)
tensor([  3.0000,   4.7500,   6.5000,   8.2500,  10.0000])
>>> min = torch.linspace(-1, 1, steps=4)
tensor([-1.0000,  -0.3333,  0.3333,  1.0000])