- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用链式法则计算成本函数相对于该层权重的斜率时L
,则公式变为:
d C0 / d W(L) = ... . d a(L) / d z(L) . ...
与:
z (L)
being the induced local field :z (L) = w1(L) * a1(L-1) + w2(L) * a2(L-1) * ...
a (L)
beeing the ouput :a (L) = & (z (L))
&
being the sigmoid function used as an activation function
请注意L
被视为图层指示器而不是索引
现在:
d a(L) / d z(L) = &' ( z(L) )
与 &'
是 sigmoid 函数的导数
问题:
但是在这个post这是 James Loy 写的关于用 python 从头开始构建一个简单的神经网络,
在进行反向传播时,他没有给出 z (L)
作为 &'
的输入替换d a(L) / d z(L)
在链式法则函数中。相反,他给了它 output = last activation of the layer (L)
作为输入的 sigmoid 导数 &'
def feedforward(self):
self.layer1 = sigmoid(np.dot(self.input, self.weights1))
self.output = sigmoid(np.dot(self.layer1, self.weights2))
def backprop(self):
# application of the chain rule to find derivative of the loss function with respect to weights2 and weights1
d_weights2 = np.dot(self.layer1.T, (2*(self.y - self.output) * sigmoid_derivative(self.output)))
请注意,在层 L
之上的代码中是层2
这是最后一层或输出层。和sigmoid_derivative(self.output)
这是当前层的激活作为 sigmoid 函数导数的输入,用作激活函数。
问题:
我们不应该使用这个sigmoid_derivative(np.dot(self.layer1, self.weights2))
而不是这个sigmoid_derivative(self.output)
?
最佳答案
事实证明,使用了&( z(L) )
或output
,只是为了适应sigmoid_derivative
的实现方式。
这是sigmoid_derivative
的代码:
def sigmoid(x):
return 1.0/(1+ np.exp(-x))
def sigmoid_derivative(x):
return x * (1.0 - x)
sigmoid_derivative
的数学公式可以写为:&' (x) = &(x) * (1-&(x))
因此,为了得到上面的公式,将 &(z)
而不是 z
传递给 sigmoid_derivative
以返回:&(z) * (1.0 - &(z))
关于python - 反向传播中 sigmoid 导数输入的困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62505150/
为什么隐藏层中主要选择 log-sigmoid 激活函数而不是 tanh-sigmoid 激活函数?另外,如果我使用 Z 分数归一化,我可以在隐藏层中使用 sigmoid 激活函数吗? 最佳答案 古代
def sigmoid(z): # complete the code z = np.asarray(z) if z.ndim == 0: return(1/(1+np.exp(-z))) e
我尝试了解 sigmoid 函数导数在神经网络中的作用。 首先,我绘制了 sigmoid 函数,以及使用 python 定义的所有点的导数。这个导数到底有什么作用呢? import numpy as
我在 java 中编写了一个 sigmoid 函数,它在处理单个数字时工作正常,但在第一个数据输入后给定数组失败时。这里有一些数据可以说明我的问题(输出四舍五入到 3 位数)。 Input |
我正在创建一个使用反向传播技术进行学习的神经网络。 我知道我们需要找到所用激活函数的导数。我正在使用标准的 sigmoid 函数 f(x) = 1 / (1 + e^(-x)) 我已经看到它的导数是
你好,我正在尝试创建一个程序来计算感知器算法的权重。我现在一切正常,但最基本的是,它是一个阶跃函数,而且是单层的。在我继续使用多层之前,我试图使其成为最优的和 sigmoid。 这就是我的问题,我对
我正在查看 this工作变分自动编码器。 主类 class VAE(nn.Module): def __init__(self): super(VAE, self).__ini
使用链式法则计算成本函数相对于该层权重的斜率时L ,则公式变为: d C0 / d W(L) = ... . d a(L) / d z(L) . ... 与: z (L) being the indu
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
使用链式法则计算成本函数相对于该层权重的斜率时L ,则公式变为: d C0 / d W(L) = ... . d a(L) / d z(L) . ... 与: z (L) being the indu
我正在使用 keras 开发深度网络。有一个激活“硬 sigmoid”。它的数学定义是什么? 我知道什么是 Sigmoid。有人在Quora上问了类似的问题:https://www.quora.com
我正在研究一些神经网络,因为它看起来很有趣。我将 python 代码翻译成 java,它的工作原理就像我想象的那样。它每次都给我正确的值。虽然我想知道你在代码中哪里实现了Sigmoid函数。我在计算输
有没有一种方法可以在不使用像 JAMA 这样的外部库的情况下找到 2D 数组的 sigmoid ?我尝试了以下代码,但失败了。 public static double[][] sigmoid(dou
我是神经网络/PyTorch 的新手。我正在尝试制作一个接受向量x的网络,第一层是h_j = w_j^T * x + b_j,输出是max_j{h_j }。唯一的事情是,我希望通过 w_j = S(k
我有一个包含 516 个号码的列表。这些数字的范围从 0 到 136661043272.12181,并且在此范围内它们分布不均匀。现在我想将这些数字标准化为[0,1],我想使用sigmoid函数,即原
我在最后一层创建了一个带有 sigmoid 激活函数的神经网络,所以我得到的结果在 0 到 1 之间。我想将事物分为 2 个类,所以我检查“数字是否 > 0.5,然后类1 其他 0 级”。都是基本的。
我创建了一个具有典型激活函数(-1 或 1)的简单感知器,它似乎工作正常。然后我阅读了有关 sigmoid 及其在值之间更平滑过渡的用途,但在使用导数时我总是得到 0.0,这会扰乱计算。 sigmoi
这是代码: import numpy as np # sigmoid function def nonlin(x,deriv=False): if(deriv==True):
我实现了一个二元逻辑回归分类器。只是为了玩,我用 tanh 替换了 sigmoid 函数 (1/1 + exp(-z))。结果完全相同,分类阈值相同,均为 0.5,尽管 tanh 的范围为 {-1,1
我使用的是 Microsoft Visual Studio 2010。 公式是y = 1/(1+exp(-e)) 在值的范围内,其中 bih.biWidth 是要迭代的范围。 然而,当我尝试在代码中实
我是一名优秀的程序员,十分优秀!