python – 为什么将误差乘以神经网络中sigmoid的导数?

python – 为什么将误差乘以神经网络中sigmoid的导数?,第1张

概述这是代码: import numpy as np# sigmoid functiondef nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x))# input datasetX = np.array([ [0,0,1], 这是代码:

import numpy as np# sigmoID functiondef nonlin(x,deriv=False):    if(deriv==True):        return x*(1-x)    return 1/(1+np.exp(-x))# input datasetX = np.array([  [0,1],[0,1,[1,1] ])# output dataset            y = np.array([[0,1]]).T# seed random numbers to make calculation# deterministic (just a good practice)np.random.seed(1)# initialize weights randomly with mean 0syn0 = 2*np.random.random((3,1)) - 1for iter in xrange(10000):    # forward propagation    l0 = X    l1 = nonlin(np.dot(l0,syn0))    # how much dID we miss?    l1_error = y - l1    # multiply how much we missed by the     # slope of the sigmoID at the values in l1    l1_delta = l1_error * nonlin(l1,True)    # update weights    syn0 += np.dot(l0.T,l1_delta)print "Output After Training:"print l1

这是网站:http://iamtrask.github.io/2015/07/12/basic-python-network/

代码的第36行,l1误差乘以用权重点缀的输入的导数.我不知道为什么这样做,并花了好几个小时试图解决它.我刚刚得出结论这是错误的,但有些事情告诉我,考虑到有多少人推荐并使用本教程作为学习神经网络的起点,这可能是不对的.

在文章中,他们说

Look at the sigmoID picture again! If the slope was really shallow
(close to 0),then the network either had a very high value,or a very
low value. This means that the network was quite confIDent one way or
the other. However,if the network guessed something close to (x=0,
y=0.5) then it isn’t very confIDent.

我似乎无法理解为什么输入sigmoID函数的高低有与置信度有关.当然,它有多高并不重要,因为如果预测的输出很低,那么它将真的不自信,不像他们所说的那样应该有信心因为它很高.

如果你想强调错误,那么将l1_error复制一下会更好吗?

这是一个真正的失望考虑到这一点,它最终看起来我找到了一个有前途的方式来真正直观地开始学习神经网络,但我又错了.如果你有一个很好的地方开始学习我可以很容易理解的地方,我们将不胜感激.

解决方法 看看这张图片.如果sigmoID函数给你一个HIGH或LOW值(非常好的信心),那个值的导数是LOW.如果得到最陡斜率(0.5)的值,则该值的导数为HIGH.

当函数给我们一个糟糕的预测时,我们希望用更高的数字改变我们的权重,相反,如果预测是好的(高信度),我们不想更改我们的权重.

总结

以上是内存溢出为你收集整理的python – 为什么将误差乘以神经网络中sigmoid的导数?全部内容,希望文章能够帮你解决python – 为什么将误差乘以神经网络中sigmoid的导数?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1194016.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存