Neural network devlog #3
I finally have a working PCNN!
What was done
After I defined the neural network, I proceeded to train it to predict XOR. However, it failed.. quite miserably.
So, I tried asking ChatGPT what was wrong with my network. But it turns out CGPT was as lost as I was, which delayed the network development.
How I fixed the bug.
After the previous attempt not working, I tried asking ChatGPT to take my existing code, and rewright it as a working example. That worked. Then, I asked another ChatGPT in a new chat to compare my existing (not working) example with the functioning example. This time, it correctly found out what’s wrong.
What was wrong.
Turns out, the theoretic structure, training, and maths behind the network was fully correct. Instead, I made many smaller mistakes that caused a simple problem seem extremely hard for the network. For example:
- Per one example, I gave the network 1000 iterations. Turns out, 50 was enough. The network therefore learned almost 20x slower.
- My network was HUGE. 5 layers, meaning 1 input layer, 1 output layer, and 3 internal layers. 1 internal layer was enough. The network didn’t quite know what to do with the rest.
- In XOR, you have input 0/1 and output 0/1. Neural networks absolutely HATE zeros. Its better to make input -1/+1 and output -1/+1.
- My learning rate was set to 0.01 to make the network ‘stable’ and not learn too quickly. After later tests, turns out it destabilizes at lr=15 and lr=1 is the best for it. At that time, CGPT recommended 0.1 which worked pretty well too.
- I used ReLU as my activation function. Tanh works way better.
- I didn’t batch the training examples.
These small mistakes combined made the network untrainable.
Process
After this, I manually fixed my network (no AI used).
Result
The network can now learn XOR in… basically 50 milliseconds.
Thanks for reading!