首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何运行2层感知器解决异或问题

如何运行2层感知器解决异或问题
EN

Stack Overflow用户
提问于 2016-10-06 22:59:18
回答 1查看 790关注 0票数 1

使用具有标准标量积和单位步长函数的单个感知器不能求解XOR。

本文建议使用3感知器创建一个网络:http://toritris.weebly.com/perceptron-5-xor-how--why-neurons-work-together.html

我试图以这种方式运行3感知器网络,但它不能为XOR生成正确的结果:

代码语言:javascript
复制
//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个感知器来解决异或:

代码语言:javascript
复制
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层。如何将这三个感知器分两层正确运行?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-07 14:37:17

如果您想要构建具有逻辑连接词的神经网络(或者不是),您必须考虑与xor相关的以下等价关系:

A×B≡(A∨B)∧‘∧(A∧B)≡(A∨B)∧(’A∨‘B)≡(A∧’B)∨(A∧B)

所以,如果你想使用你的感知器,如果我理解正确的话,你至少需要三个和-或-或-感知器和一个否定。在本文中,他们使用具有特殊权重的三个百分位数作为xor。这些都不是和感知器相同的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39906890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档