公众号【计算机视觉联盟】后台回复【PyTorch】可以获得独家PyTorch学习教程pdf版
通过torch.linspace创建均分数列 张量
步长=(Start - end)/(Steps - 1)
t = torch.linspace(2,10,5)
print("torch.linspace(2,10,5)的输出结果\n",t)
t = torch.linspace(2,10,6)
print("torch.linspace(2,10,6)的输出结果\n",t)
运行结果:
torch.linspace(2,10,5)的输出结果
tensor([ 2., 4., 6., 8., 10.])
torch.linspace(2,10,6)的输出结果
tensor([ 2.0000, 3.6000, 5.2000, 6.8000, 8.4000, 10.0000])
推荐阅读:
PyTorch | torch.from_numpy使用方法