PyTorch ile Deep Learning'e Giriş
Jasmin Ludolf
Senior Data Science Content Developer, DataCamp
$$

| Saç | Tüy | Yumurta | Süt | Yüzgeç | Bacak | Kuyruk | Evcil | Kedi boyutu | Sınıf |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 1 | 0 | 4 | 0 | 0 | 1 | 0 |
$$
$$
[-5.2, 4.6, 0.8]
import torch.nn.functional as F
print(F.one_hot(torch.tensor(0), num_classes = 3))
tensor([1, 0, 0])
print(F.one_hot(torch.tensor(1), num_classes = 3))
tensor([0, 1, 0])
print(F.one_hot(torch.tensor(2), num_classes = 3))
tensor([0, 0, 1])
from torch.nn import CrossEntropyLoss scores = torch.tensor([-5.2, 4.6, 0.8]) one_hot_target = torch.tensor([1, 0, 0])criterion = CrossEntropyLoss()print(criterion(scores.double(), one_hot_target.double()))
$$
tensor(9.8222, dtype=torch.float64)
Kayıp fonksiyonu şunları alır:
Kayıp fonksiyonu şunları döndürür:

PyTorch ile Deep Learning'e Giriş