Torch-单层感知机 单层感知机 多输出感知机 单层感知机 单层感知机: 激活函数为sigmoid函数。 下面我们推导输出误差的公式,及其梯度。其中我们使用的sigmoid函数作为激活函数 然后通过代码来实现感知机梯度的计算 import torch from torch.nn import functional as F x=torch.randn(1,10)#使用十号节点的输入,也就是输入x的特征值有10个 w=torch.randn(1,10,requires_grad=True) o=torch.sigmoid(x@w