ShusenTang / Dive-into-DL-PyTorch

本项目将《动手学深度学习》(Dive into Deep Learning)原书中的MXNet实现改为PyTorch实现。
http://tangshusen.me/Dive-into-DL-PyTorch
Apache License 2.0
18.07k stars 5.37k forks source link

3.9节的net中是否要加入softmax #182

Open Riqzz opened 2 years ago

Riqzz commented 2 years ago

这里在return时不需要softmax吗?

def net(X):
    X = X.view((-1, num_inputs))
    H = relu(torch.matmul(X, W1) + b1)
    return torch.matmul(H, W2) + b2
qizihaoliuliuliu commented 2 years ago

哈哈,兄弟你稍微往下看一点,在3.9.5中介绍了,在pytorch损失函数自带的torch.nn.CrossEntropyLoss()交叉熵损失函数中已经带了softmax运算啦!~