Skip to content
Advertisement

simple Neural Network gives random prediction result

I have been trying to build a simple neural network myself (3 layers) to predict the MNIST dataset. I referenced some codes online and wrote some parts my own, the code runs without any errors, but something is wrong with the learning process. It seems like the prediction result is all “random”. Applying the learning process to the network and use the network to predict the same image always gives me different results every time. Could someone please give me some hints where I did wrong?

JavaScript

Put functions together

JavaScript

Running the code three times the results are like

JavaScript

Running the same code three times, I’m having three largely different results. I know there are randomness in neural netowrk, but isn’t the parameters about the same after learning process? Could anyone please give me some hints or suggestion where I did wrong in the learning process or what causes the randomness in the result?

Advertisement

Answer

Given the code itself is correct, I would increase the learning rate and increase the number of epochs. You even decrease the learning rate every epoch (lr=lr/10). Feels like the model doesn’t have the time to converge (to actually learn). For starters, I would fix the learning rate at 0.001 and increase the number of epochs to maybe 25? If your results get better you can start fiddling around.

Advertisement