torch.linspace()

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])

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章