神经网络不匹配预期输出

huangapple go评论51阅读模式
英文:

Neural Network doesn't match the expected output

问题

我正在尝试从头开始构建一个神经网络,只使用numpy。我有以下的代码和函数。然而,训练后的输出与我期望的输出不匹配(以XOR作为示例)。我认为我的其中一个函数可能不正确,但无法找出错误。我得到的输出例如是:[[0.73105858], [0.53336314], [0.79343002], [0.5786911]],这与期望的输出[0, 0, 0, 1]不接近。

英文:

I am trying to build a Neural Network from scratch, using only numpy. I have the following code and functions. However, the output after the training is not matching the expected output that i have (using XOR as an example). I think one of my functions is not correct but cannot figure out the mistake. The output I get is, for example: [[0.73105858], [0.53336314],[0.79343002],[0.5786911 ]], which is not close to the expected output [0,0,0,1]

答案1

得分: 4

你的神经网络进行了2次迭代训练,学习率为0.01。这意味着你的网络只进行了2次更新,并且更新的幅度很小,导致神经网络训练不足。此外,你总是使用大小为4*4的张量作为输入,这意味着神经网络只针对所有样本的平均值进行更新,因此结果看起来只是一个平均值。

为了改进,我的建议是增加迭代次数,同时增加每次迭代的样本数量,并确保每次迭代进行多次更新。尽管如此,我相信你不会得到100%准确的结果,因为对于XOR问题,你只使用了一个线性层,无法仅通过一个线性系统解决。你可以考虑添加另一个层以获得更好的结果。

英文:

I don't so any issues with your code, but here are some thing you should have in mind:

Your neural network is trained for 2 iterations, with a learning rate of 0.01. This means that your network is only updated 2 times with a small rate of improvement resulting in an undertrained neural network. Also, your always using a tensor of the size 4*4 for input, meaning that the neural network is only updated for the average of all samples, hence the result that just seems like an average.

For improvement, my suggestion would be to increase the number of iterations and also increase the number of samples for each iterations, also making sure that each iteration has more than one update. Still, i believe that you won't get 100% accurate results, since you are only using one linear layer for XOR, which can't be solved with just one linear system. You could consider adding another layer for better results.

huangapple
  • 本文由 发表于 2023年2月17日 23:43:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486413.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定