Should I use softmax as output when using cross entropy loss in pytorch?

前端 未结 1 2024
故里飘歌
故里飘歌 2020-12-10 13:54

I have a problem with classifying fully connected deep neural net with 2 hidden layers for MNIST dataset in pytorch.

I want to use tanh

1条回答
  •  旧巷少年郎
    2020-12-10 14:37

    As stated in the torch.nn.CrossEntropyLoss() doc:

    This criterion combines nn.LogSoftmax() and nn.NLLLoss() in one single class.

    Therefore, you should not use softmax before.

    0 讨论(0)
提交回复
热议问题