In understanding what a neural network really helped, this article Habra. In principle, I try it.

The fact is that, it seems, two hidden neurons are not enough to train the XOR neural network. At least according to this algorithm. Because in the end, for input values ​​1 and 1, the result in the process of learning is stuck at 0.52-0.57. Ie, roughly speaking in the middle. This is after 1,000,000 epochs.

I tried to increase the number of neurons to 3, tug-of-war (result for 1 and 1) remains until about 70.000 epochs, then the system finds a solution.

A larger number of neurons allows you to quickly train the system? Or how? How to determine the number of neurons on a layer and the number of layers? I have never seen an exact explanation on this.

  • It's not about speed, but the fact that xor is fundamentally impossible to implement on a single-layer network. See for example the question The essence of the problem is exclusive or - insolor
  • But it worked for me on a single layer. It turns out 2 input neurons, 3 hidden and 1 output. Only layers with hidden neurons are considered as layers. - user64675
  • You have training stuck in the middle, which means that for example with any input data you will have a response of 0.5 instead of 0 or 1. This means that the single-layer one did not work. - insolor
  • Not, that's just the point, I'm stuck when there are 2 neurons on the hidden layer (as recommended in the tutorial). When I increase to 3, everything works. - user64675 5:38 pm
  • And about bias not forgotten? - Alexandr

1 answer 1

In general, the thing was that I had a very high learning rate (0.7, as in the article). Therefore, something like this happened: enter image description here

After I reduced the learning rate to 0.1, for ~ 100,000 epochs everything was calculated.

Unfortunately, I haven’t seen any normal answers to the rest of my question.