hanbt / learn_dl

Deep learning algorithms source code for beginners
Apache License 2.0
1.19k stars 988 forks source link

感知机的梯度求导疑问 #37

Closed xinghalo closed 5 years ago

xinghalo commented 5 years ago

好奇,再做梯度更新的时候,为什么梯度是label-output。 在《统计学习方法》里面,梯度更新的规则是 w = w + αyixi

def _update_weights(self, input_vec, output, label, rate):
        delta = label - output
        print("delta\t: %f" % delta)
        self.weights = [w + rate * delta * x for (x, w) in zip(input_vec, self.weights)]
        self.bias += rate * delta
        print(self)
xinghalo commented 5 years ago

原来是公式推导简化而来的,看完第二篇,就明白了