Function details:
torch.linspace(start, end, steps, out)
- Function : generate uniform N points on the interval [start, end].
- Parameters :
- start (float) : the starting point of the interval;
- end (float) : the end point of the interval;
- steps(int) : the number of points generated;
- out (Tensor, optional) : The result tensor.
- Note : start can be smaller than end, larger than end, or equal to end.
Example:
import torch
a = torch.linspace(0, 1, 5)
print(a) ## tensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000])
a = torch.linspace(1, 0, 5)
print(a) ## tensor([1.0000, 0.7500, 0.5000, 0.2500, 0.0000])
a = torch.linspace(1, 1, 5)
print(a) ## tensor([1., 1., 1., 1., 1.])