我知道梯度下降和反向传播算法。我不明白的是:什么时候使用偏见是重要的,你如何使用它?
例如,在映射AND函数时,当我使用两个输入和一个输出时,它不会给出正确的权重。然而,当我使用三个输入(其中一个是偏差)时,它给出了正确的权重。
我知道梯度下降和反向传播算法。我不明白的是:什么时候使用偏见是重要的,你如何使用它?
例如,在映射AND函数时,当我使用两个输入和一个输出时,它不会给出正确的权重。然而,当我使用三个输入(其中一个是偏差)时,它给出了正确的权重。
当前回答
Two different kinds of parameters can be adjusted during the training of an ANN, the weights and the value in the activation functions. This is impractical and it would be easier if only one of the parameters should be adjusted. To cope with this problem a bias neuron is invented. The bias neuron lies in one layer, is connected to all the neurons in the next layer, but none in the previous layer and it always emits 1. Since the bias neuron emits 1 the weights, connected to the bias neuron, are added directly to the combined sum of the other weights (equation 2.1), just like the t value in the activation functions.1
它不实用的原因是,您同时调整权重和值,因此对权重的任何更改都会抵消对先前数据实例有用的值的更改……在不改变值的情况下添加偏置神经元可以让你控制层的行为。
此外,偏差允许您使用单个神经网络来表示类似的情况。考虑由以下神经网络表示的AND布尔函数:
(来源:aihorizon.com)
W0对应于b。 W1对应x1。 W2对应于x2。
A single perceptron can be used to represent many boolean functions. For example, if we assume boolean values of 1 (true) and -1 (false), then one way to use a two-input perceptron to implement the AND function is to set the weights w0 = -3, and w1 = w2 = .5. This perceptron can be made to represent the OR function instead by altering the threshold to w0 = -.3. In fact, AND and OR can be viewed as special cases of m-of-n functions: that is, functions where at least m of the n inputs to the perceptron must be true. The OR function corresponds to m = 1 and the AND function to m = n. Any m-of-n function is easily represented using a perceptron by setting all input weights to the same value (e.g., 0.5) and then setting the threshold w0 accordingly. Perceptrons can represent all of the primitive boolean functions AND, OR, NAND ( 1 AND), and NOR ( 1 OR). Machine Learning- Tom Mitchell)
阈值是偏置,w0是与偏置/阈值神经元相关的权重。
其他回答
术语偏差用于调整最终输出矩阵,就像y截距一样。例如,在经典方程y = mx + c中,如果c = 0,那么直线将始终经过0。添加偏差项为我们的神经网络模型提供了更大的灵活性和更好的泛化。
偏差决定了你的体重旋转的角度。
在二维图表中,权重和偏差可以帮助我们找到输出的决策边界。
假设我们需要构建一个AND函数,输入(p)-输出(t)对应该是
{p=[0,0], t=0},{p=[1,0], t=0},{p=[0,1], t=0},{p=[1,1], t=1}
现在我们需要找到一个决策边界,理想的边界应该是:
看到了吗?W垂直于边界。因此,我们说W决定了边界的方向。
但是,第一次找到正确的W是很困难的。大多数情况下,我们随机选择原始W值。因此,第一个边界可能是这样的:
现在边界平行于y轴。
我们要旋转边界。如何?
通过改变W。
因此,我们使用学习规则函数W'=W+P:
W'=W+P等价于W'=W+ bP,而b=1。
因此,通过改变b(bias)的值,就可以决定W’和W之间的夹角,这就是“ANN的学习规则”。
你也可以阅读Martin T. Hagan / Howard B. Demuth / Mark H. Beale的《神经网络设计》,第4章“感知器学习规则”。
Two different kinds of parameters can be adjusted during the training of an ANN, the weights and the value in the activation functions. This is impractical and it would be easier if only one of the parameters should be adjusted. To cope with this problem a bias neuron is invented. The bias neuron lies in one layer, is connected to all the neurons in the next layer, but none in the previous layer and it always emits 1. Since the bias neuron emits 1 the weights, connected to the bias neuron, are added directly to the combined sum of the other weights (equation 2.1), just like the t value in the activation functions.1
它不实用的原因是,您同时调整权重和值,因此对权重的任何更改都会抵消对先前数据实例有用的值的更改……在不改变值的情况下添加偏置神经元可以让你控制层的行为。
此外,偏差允许您使用单个神经网络来表示类似的情况。考虑由以下神经网络表示的AND布尔函数:
(来源:aihorizon.com)
W0对应于b。 W1对应x1。 W2对应于x2。
A single perceptron can be used to represent many boolean functions. For example, if we assume boolean values of 1 (true) and -1 (false), then one way to use a two-input perceptron to implement the AND function is to set the weights w0 = -3, and w1 = w2 = .5. This perceptron can be made to represent the OR function instead by altering the threshold to w0 = -.3. In fact, AND and OR can be viewed as special cases of m-of-n functions: that is, functions where at least m of the n inputs to the perceptron must be true. The OR function corresponds to m = 1 and the AND function to m = n. Any m-of-n function is easily represented using a perceptron by setting all input weights to the same value (e.g., 0.5) and then setting the threshold w0 accordingly. Perceptrons can represent all of the primitive boolean functions AND, OR, NAND ( 1 AND), and NOR ( 1 OR). Machine Learning- Tom Mitchell)
阈值是偏置,w0是与偏置/阈值神经元相关的权重。
神经网络中没有偏差的一层只不过是输入向量与矩阵的乘法。(输出向量可以通过一个sigmoid函数进行归一化,然后用于多层人工神经网络,但这并不重要。)
这意味着你在使用一个线性函数,因此一个全0的输入将总是映射到一个全0的输出。对于某些系统,这可能是一个合理的解决方案,但一般来说,它的限制太大了。
使用偏置,可以有效地为输入空间增加另一个维度,它总是取值1,因此可以避免输入向量全为0。你不会因此失去任何一般性,因为你训练的权重矩阵不需要是满射的,所以它仍然可以映射到之前可能的所有值。
二维安:
对于一个将二维映射到一维的ANN,就像在复制AND或or(或XOR)函数一样,你可以把一个神经元网络想象成做以下事情:
在二维平面上标记输入向量的所有位置。为布尔值,你想标记(1,1),(1,1),(1,1),(1,1)。你的人工神经网络现在做的是在二维平面上画一条直线,把正输出和负输出分开。
如果没有偏差,这条直线必须经过零,而有偏差,你可以把它放在任何地方。 因此,您将看到,如果没有偏差,您将面临与函数的问题,因为您不能同时将(1,-1)和(-1,1)放在负一侧。(他们不允许在线。)对于OR函数,问题是相等的。然而,有了偏见,就很容易划清界限。
请注意,在这种情况下,异或函数即使有偏差也无法求解。
偏差有助于得到更好的方程。
想象一下,输入和输出就像一个函数y = ax + b,你需要在输入(x)和输出(y)之间画一条正确的线,以最小化每个点和直线之间的全局误差,如果你保持这样的方程y = ax,你将只有一个参数用于适应,即使你找到了最小化全局误差的最佳参数,它也会离你想要的值很远。
你可以说,偏差使方程更灵活,以适应最佳值