向后传递
feedforward()
实现向后传递的功能。
向后传递的公式:
w和b为某个神经上的参数,a为上层的输出,a'为这个神经元的输出。
def feedforward(self, a):
"""Return the output of the network if "a" is input."""
for b, w in zip(self.biases, self.weights):
a = sigmoid(np.dot(w, a)+b)
return a
def sigmoid(z):
return 1.0/(1.0+np.exp(-z))
sigmoid函数用于实现,需注意的是入参z是一个向量。 sigmoid函数是对整个向量计算的。
Last updated
Was this helpful?