使用pytorch构建神经网络系列
第三章 第一节梯度下降
目录
1.激活函数 Activation Function
Sigmoid / Logistic
求导步骤:
torch.sigmoid
Tanh
tanh函数求导
torch.tanh
Rectified Linear Unit(ReLU)
ReLU函数求导:
F.relu
2.损失函数Loss 及其梯度
Typical Loss:
- Mean Squared Error
- Cross Entropy Loss
MSE
函数求导:
autograd.grad
注意:对函数进行求导时需要将tensor设置需要求导信息:
w.requires_grad_() or require_grad = True