# Behaviour of cost

In doing a project using neural networks with an input layer, 4 hidden layers and an output layer ,I used mini batch gradient descent. I noticed that the randomly initialised weights seemed to do a good performance and gave a low error. As the model started training after about 200 iterations there was large jump in error and then it came down slowly from there. I have also noticed that sometimes the cost just increases over a set of consecutive iterations. Can anyone explain why these happen? It is not like there are outliers or a new distribution as every iteration exposes it to the entire dataset. I used learning rate 0.01 and regularisation parameter 10. I also tried regularisation parameter 5 and also 1. And by the cost I mean, the sum of squared errors of all minibatches/2m plus regularisation term error. Further if this happens and my cost after the say 10000th iteration is more than my cost when I initialised with random weights (lol) can I just take the initial value? As those weights seem to be doing better.

The large jumps are the most puzzling.

This is the code

Any help would be greatly appreciated. Thanks

I would say just don't go for using regularization at first, try with lower learning rate = 0.0001 see the behavior. Try to post entire architecture of your model so that one can better answer your problem.