Dive-into-DL-PyTorch icon indicating copy to clipboard operation
Dive-into-DL-PyTorch copied to clipboard

3.9节的net中是否要加入softmax

Open Riqzz opened this issue 2 years ago • 1 comments

这里在return时不需要softmax吗?

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

Riqzz avatar Dec 11 '21 10:12 Riqzz

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

qizihaoliuliuliu avatar Mar 03 '22 02:03 qizihaoliuliuliu