Dive-into-DL-PyTorch
Dive-into-DL-PyTorch copied to clipboard
3.9节的net中是否要加入softmax
这里在return时不需要softmax吗?
def net(X):
X = X.view((-1, num_inputs))
H = relu(torch.matmul(X, W1) + b1)
return torch.matmul(H, W2) + b2
哈哈,兄弟你稍微往下看一点,在3.9.5中介绍了,在pytorch损失函数自带的torch.nn.CrossEntropyLoss()交叉熵损失函数中已经带了softmax运算啦!~