我知道梯度下降和反向传播算法。我不明白的是:什么时候使用偏见是重要的,你如何使用它?
例如,在映射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是与偏置/阈值神经元相关的权重。
其他回答
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=0或y=1所限制,可能是在某个分类任务中……例如,对于某些x=(1,1),有些y=0,对于某些x=(0,1),有些y=1。(假设/结果的条件是我上面谈到的阈值。注意,我的示例设置输入X为每个X =一个双值或2值向量,而不是Nate的某个集合X的单值X输入)。
如果我们忽略偏差,许多输入可能最终由许多相同的权重表示(即学习的权重大多出现在原点附近(0,0)。 这样,模型就会被限制在较差的好权重上,而不是在有偏差的情况下更好地学习更多的好权重。(学习不好的权重会导致更差的猜测或神经网络的猜测能力下降)
因此,模型既要在靠近原点的地方学习,又要在阈值/决策边界内尽可能多的地方学习,这是最优的。有了偏差,我们可以使自由度接近原点,但不限于原点的直接区域。
扩展zfy的解释:
一个输入,一个神经元,一个输出的方程如下:
y = a * x + b * 1 and out = f(y)
其中x是输入节点的值,1是偏置节点的值; Y可以直接作为输出,也可以传递给一个函数,通常是一个sigmoid函数。还要注意,偏差可以是任何常数,但为了使一切更简单,我们总是选择1(可能这太常见了,zfy没有显示和解释它)。
你的网络试图学习系数a和b来适应你的数据。 所以你可以看到为什么添加元素b * 1可以让它更好地适应更多的数据:现在你可以改变斜率和截距。
如果你有一个以上的输入,你的方程将是这样的:
y = a0 * x0 + a1 * x1 + ... + aN * 1
请注意,这个方程仍然描述一个神经元,一个输出网络;如果你有更多的神经元,你只需在系数矩阵中增加一个维度,将输入相乘到所有节点,然后将每个节点的贡献相加。
可以写成向量化的形式
A = [a0, a1, .., aN] , X = [x0, x1, ..., 1]
Y = A . XT
即,将系数放在一个数组中,(输入+偏差)放在另一个数组中,你就有了你想要的解决方案,作为两个向量的点积(你需要转置X的形状是正确的,我写了XT a 'X转置')
所以最后你也可以看到你的偏差只是一个输入来代表输出的那部分实际上是独立于你的输入的。
简单来说,如果你有y=w1*x,其中y是你的输出,w1是权重,想象一个条件,x=0,那么y=w1*x等于0。
如果你想要更新你的权重,你必须计算delw=target-y的变化量,其中target是你的目标输出。在这种情况下,'delw'将不会改变,因为y被计算为0。所以,假设你可以添加一些额外的值,这将有助于y = w1x + w01,其中偏差=1,权重可以调整以获得正确的偏差。考虑下面的例子。
就直线斜率而言,截距是线性方程的一种特殊形式。
Y = mx + b
检查图像
图像
这里b是(0,2)
如果你想把它增加到(0,3)你怎么通过改变b的值来实现呢?
下面是一些进一步的插图,展示了一个简单的2层前馈神经网络在一个双变量回归问题上的结果。权重被随机初始化,并使用标准的ReLU激活。正如我前面的答案所总结的那样,没有偏差,relu网络无法在(0,0)处偏离零。