我知道梯度下降和反向传播算法。我不明白的是:什么时候使用偏见是重要的,你如何使用它?
例如,在映射AND函数时,当我使用两个输入和一个输出时,它不会给出正确的权重。然而,当我使用三个输入(其中一个是偏差)时,它给出了正确的权重。
我知道梯度下降和反向传播算法。我不明白的是:什么时候使用偏见是重要的,你如何使用它?
例如,在映射AND函数时,当我使用两个输入和一个输出时,它不会给出正确的权重。然而,当我使用三个输入(其中一个是偏差)时,它给出了正确的权重。
当前回答
下面是一些进一步的插图,展示了一个简单的2层前馈神经网络在一个双变量回归问题上的结果。权重被随机初始化,并使用标准的ReLU激活。正如我前面的答案所总结的那样,没有偏差,relu网络无法在(0,0)处偏离零。
其他回答
偏见是我们的锚。对我们来说,这是一种设定底线的方式,我们不会低于这个标准。从图的角度来看,y=mx+b就像这个函数的y轴截距。
输出=输入乘以权重值并加上偏置值,然后应用激活函数。
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是与偏置/阈值神经元相关的权重。
下面是一些进一步的插图,展示了一个简单的2层前馈神经网络在一个双变量回归问题上的结果。权重被随机初始化,并使用标准的ReLU激活。正如我前面的答案所总结的那样,没有偏差,relu网络无法在(0,0)处偏离零。
我认为偏见几乎总是有益的。实际上,偏差值允许您将激活函数向左或向右移动,这可能对成功学习至关重要。
看一个简单的例子可能会有所帮助。考虑这个无偏差的1输入1输出网络:
网络的输出是通过将输入(x)乘以权重(w0)并将结果传递给某种激活函数(例如sigmoid函数)来计算的。
下面是这个网络计算的函数,对于不同的w0值:
改变权重w0本质上改变了s型曲线的“陡度”。这很有用,但是如果你想让x = 2时网络输出0呢?仅仅改变s型曲线的陡度是行不通的——你希望能够将整条曲线向右平移。
这正是偏差允许你做的。如果我们给这个网络加上一个偏差,像这样:
...然后网络的输出变成sig(w0*x + w1*1.0)。下面是不同w1值的网络输出:
如果w1的权值为-5,曲线就会向右平移,这样当x = 2时,网络的输出就会为0。
术语偏差用于调整最终输出矩阵,就像y截距一样。例如,在经典方程y = mx + c中,如果c = 0,那么直线将始终经过0。添加偏差项为我们的神经网络模型提供了更大的灵活性和更好的泛化。