使用具有标准标量积和单位步长函数的单个感知器不能求解XOR。
本文建议使用3感知器创建一个网络:http://toritris.weebly.com/perceptron-5-xor-how--why-neurons-work-together.html
我试图以这种方式运行3感知器网络,但它不能为XOR生成正确的结果:
//pseudocode
class perceptron {
constructor(training_data) {
this.training_data = training_data
}
train() {
iterate multiple times over training data
to train weights
}
unit_step(value) {
if (value<0) return 0
else return 1
}
compute(input) {
weights = this.train()
sum = scalar_product(input,weights)
return unit_step(sum)
}
}上述感知器可以正确地解决NOT,和,OR位运算。这就是我如何使用3个感知器来解决异或:
AND_perceptron = perceptron([
{Input:[0,0],Output:0},
{Input:[0,1],Output:0},
{Input:[1,0],Output:0},
{Input:[1,1],Output:1}
])
OR_perceptron = perceptron([
{Input:[0,0],Output:0},
{Input:[0,1],Output:1},
{Input:[1,0],Output:1},
{Input:[1,1],Output:1}
])
XOR_perceptron = perceptron([
{Input:[0,0],Output:0},
{Input:[0,1],Output:1},
{Input:[1,0],Output:1},
{Input:[1,1],Output:0}
])
test_x1 = 0
test_x2 = 1
//first layer of perceptrons
and_result = AND_perceptron.compute(test_x1,test_x2)
or_result = OR_perceptron.compute(test_x1,test_x2)
//second layer
final_result = XOR_perceptron.compute(and_result,or_result)上面的final_result是不一致的,有时0,有时1。似乎我错误地运行了2层。如何将这三个感知器分两层正确运行?
发布于 2016-10-07 14:37:17
如果您想要构建具有逻辑连接词的神经网络(或者不是),您必须考虑与xor相关的以下等价关系:
A×B≡(A∨B)∧‘∧(A∧B)≡(A∨B)∧(’A∨‘B)≡(A∧’B)∨(A∧B)
所以,如果你想使用你的感知器,如果我理解正确的话,你至少需要三个和-或-或-感知器和一个否定。在本文中,他们使用具有特殊权重的三个百分位数作为xor。这些都不是和感知器相同的。
https://stackoverflow.com/questions/39906890
复制相似问题