5,323
edits
(→Memory) |
|||
Line 84: | Line 84: | ||
This can result in a minor performance hit if you repeatedly use a contiguous tensor with a channels last tensor. | This can result in a minor performance hit if you repeatedly use a contiguous tensor with a channels last tensor. | ||
To address this, call [https://pytorch.org/docs/stable/tensors.html#torch.Tensor.contiguous <code>contiguous</code>] on the tensor with the new memory format. | To address this, call [https://pytorch.org/docs/stable/tensors.html#torch.Tensor.contiguous <code>contiguous</code>] on the tensor with the new memory format. | ||
==Classification== | |||
In classification, your model outputs a vector of ''logits''. | |||
These are relative scores for each potential output class. | |||
To compute the loss, pass the logits into a [https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html cross-entropy loss]. | |||
To compute the accuracy, you can use [https://pytorch.org/docs/stable/generated/torch.argmax.html <code>torch.argmax</code>] to get the top prediction or [https://pytorch.org/docs/stable/generated/torch.topk.html <code>torch.topk</code>] to get the top-k prediction. | |||
==TensorBoard== | ==TensorBoard== |