Beli Saya Kopi☕
*Memo:
linspace() boleh mencipta tensor 1D bagi sifar atau lebih integer, nombor titik terapung atau nombor kompleks dijarakkan sama rata antara mula dan tamat(mula<=x<=akhir) seperti ditunjukkan di bawah:
*Memo:
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])
Atas ialah kandungan terperinci linspace dalam PyTorch. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!