rasbt/machine-learning-book

Chapter 13, Page 438. Missing the final activation function (SoftMax)

acmoudleysa opened this issue · 1 comments

The note mentions that the softmax function is used at the end, but it's missing in the code you've provided.

all_layers.append(nn.Linear(hidden_units[-1], 10))

To be added:
all_layers.append(torch.softmax(dim=1))

rasbt commented

Hi there, thanks for the note. The Softmax function should not be included of you use CrossEntropyLoss in PyTorch since the loss already performs Softmax implicitly. Thanks for commenting, though. Let me know if you have any questions, happy to discuss.