从PyTorch的官方网站上找到了这个函数的详细说明。
torch.linspace
(start, end, steps=100, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor
函数的作用是,返回一个一维的tensor(张量),这个张量包含了从start到end,分成steps个线段得到的向量。
linspace(s,e,steps) | 从s到e,均匀切分成steps份 |
常用的几个变量:
start:开始值
end:结束值
steps:分割的点数,默认是100
dtype:返回值(张量)的数据类型
举例:
import torch
a = torch.linspace(0, 15, 6)
print(a)