简体   繁体   English

从头开始测试神经网络构建 (XOR)

[英]Testing Neural Network build from scratch (XOR)

So, I have recently implemented a neural network from scratch in python by following 3Blue1Brown's videos and I am currently doing the testing part of my implementation.所以,我最近通过关注 3Blue1Brown 的视频从头开始在 python 中实现了一个神经网络,我目前正在做我的实现的测试部分。 This is done by doing the AND, OR, and XOR problems.这是通过执行 AND、OR 和 XOR 问题来完成的。 It seems like the network works in the AND and OR problems, however, not in the XOR problem.网络似乎适用于 AND 和 OR 问题,但不适用于 XOR 问题。 I Get the following predictions:我得到以下预测:

AND

Input:     Output:
0, 0       0.048
1, 0       0.018
0, 1       0.020
1, 1       0.974

OR或者

Input:     Output:
0, 0       0.026
1, 0       0.984
0, 1       0.988
1, 1       0.997

XOR异或

Input:     Output:
0, 0       0.049
1, 0       0.842
0, 1       0.842
1, 1       0.844 <- WRONG!

These results have been predicted with a model of 1 hidden layer with 2 neurons, and the sigmoid function in both the hidden layer and in the output layer.这些结果是用 1 个隐藏层和 2 个神经元的模型以及隐藏层和输出层中的 sigmoid 函数预测的。

I have tried different amounts of testing data, epochs, dimensions in the hidden layers, and hidden layers, and nothing seems to work.我尝试了不同数量的测试数据、时期、隐藏层和隐藏层中的维度,但似乎没有任何效果。

So, my question is if anyone has any idea why i get the wrong result in the XOR problem but not in the AND and the OR problems?所以,我的问题是,是否有人知道为什么我在 XOR 问题中得到错误结果,而在 AND 和 OR 问题中却没有得到错误结果? And if so, how to fix it?如果是这样,如何解决?

typically the XOR function requires a more complex model.通常,XOR 函数需要更复杂的模型。 Add another hidden layer of two neurons and that should be sufficient.添加两个神经元的另一个隐藏层,这应该就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM