請我喝杯咖啡☕
*備忘錄:
linspace() 可以建立零個或多個在 start 和 end 之間均勻間隔的整數、浮點數或複數的一維張量(start
*備忘錄:
import torch torch.linspace(start=10, end=20, steps=0) torch.linspace(start=20, end=10, steps=0) # tensor([]) torch.linspace(start=10., end=20., steps=1) tensor([10.]) torch.linspace(start=20, end=10, steps=1) # tensor([20.]) torch.linspace(start=10., end=20., steps=2) # tensor([10., 20.]) torch.linspace(start=20, end=10, steps=2) # tensor([20., 10.]) torch.linspace(start=10., end=20., steps=3) # tensor([10., 15., 20.]) torch.linspace(start=20, end=10, steps=3) # tensor([20., 15., 10.]) torch.linspace(start=10., end=20., steps=4) # tensor([10.0000, 13.3333, 16.6667, 20.0000]) torch.linspace(start=20., end=10., steps=4) # tensor([20.0000, 16.6667, 13.3333, 10.0000]) torch.linspace(start=10, end=20, steps=4, dtype=torch.int64) torch.linspace(start=torch.tensor(10), end=torch.tensor(20), steps=torch.tensor(4), dtype=torch.int64) # tensor([10.0000, 13.3333, 16.6667, 20.0000]) torch.linspace(start=10.+6.j, end=20.+3.j, steps=4) torch.linspace(start=torch.tensor(10.+6.j), end=torch.tensor(20.+3.j), steps=torch.tensor(4)) # tensor([10.0000+6.j, 13.3333+5.j, 16.6667+4.j, 20.0000+3.j]) torch.linspace(start=False, end=True, steps=4) torch.linspace(start=torch.tensor(True), end=torch.tensor(False), steps=torch.tensor(4)) # tensor([0.0000, 0.3333, 0.6667, 1.0000]) torch.linspace(start=10, end=20, steps=4, dtype=torch.int64) torch.linspace(start=torch.tensor(10), end=torch.tensor(20), steps=torch.tensor(4), dtype=torch.int64) # tensor([10.0000, 13.3333, 16.6667, 20.0000])
以上是PyTorch 中的 linspace的詳細內容。更多資訊請關注PHP中文網其他相關文章!