CodingTrain / Toy-Neural-Network-JS

Neural Network JavaScript library for Coding Train tutorials
MIT License
425 stars 242 forks source link

Unexpected behavior on adding multiple hidden layers #139

Open renansd opened 5 years ago

renansd commented 5 years ago

I've modified the NeuralNetwork code so the class constructor receives the number of hidden layers and the number of nodes per hidden layer, also modifying the guess and training functions to work with multiple hidden layers. It seems to work but, in the XOR example, as I create NNs with increasing number of hidden layers, the results come back wrong more and more frequently, to the point of at 5 hidden layers I always get wrong answers. Is it something I should expect or maybe there's something wrong with my implementation? My code: https://pastebin.com/iF8UVhSU

GypsyDangerous commented 5 years ago

I have not looked at your code so there could be something wrong there but I have experienced with my own from-scratch NN that for simple tasks like XOR having lots of hidden layers makes it worse.