PyTorch中的torch.linspace
linspace是linear space的縮寫,中文含義是線性等分向量
原函數
torch.linspace(start, end, steps=100, out=None, dtype=None,layout=torch.strided, device=None, requires_grad=False)
參數
start: 開始值
end:結束值
steps:分割的點數,默認爲100
示例代碼
import torch
print(torch.linspace(1, 10, 5))
#輸出結果:
tensor([ 1.0000, 3.2500, 5.5000, 7.7500, 10.0000])