Skip to content
ml-recall

#nll-loss

1 question from PyTorch

Timed test

1 question · 1 min · score and explanations at the end

Take a test
Q 1 / 1Score 0 / 0

Question 1: Single choice

mediumAI-checkedPyTorch

A pretrained DenseNet gets a new classifier and loss:

model.classifier = nn.Sequential(nn.Linear(1024, 256), nn.ReLU(), nn.Dropout(0.2),
                                 nn.Linear(256, 2), nn.LogSoftmax(dim=1))
criterion = nn.NLLLoss()

Why is NLLLoss the right loss here rather than nn.CrossEntropyLoss?

Choose one option