Код: Выделить всё
import torch.nn as nn
outputs = model(inputs) # Example ResNet18
criterion = nn.CrossEntropyLoss()
loss = criterion(outputs, labels)
loss.backward()
Подробнее здесь: https://stackoverflow.com/questions/786 ... unction-in
Код: Выделить всё
import torch.nn as nn
outputs = model(inputs) # Example ResNet18
criterion = nn.CrossEntropyLoss()
loss = criterion(outputs, labels)
loss.backward()