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


2 Answers 2


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.

  • $\begingroup$ Yeah. I had posted the code. Tried Xavier initialisation. Decreased cost down to 0.0000075 and it converges fine. So I took it down. $\endgroup$
    – pranav
    Aug 3, 2018 at 7:04

I figured out the problem after a bit of trial and error. This article may help too

First i set about pruning the dataset and removed outliers. Then i initialised the weights to better values using xavier initialisation. These made the model slightly better but still the problem occured.

I then set the learning rate down to 0.000000075 and it converged after about 10000 iterations. I guess it was overshooting the minimum and reaching a point on the other side of the minimum that was farther than the previous point. This resulted in increased magnitude of gradient in the opposite direction and the cost explosively went up to the order of billions.

  • $\begingroup$ That is an unlikely learning rate, I have never seen anyone use that small learning rate $\endgroup$
    – user9947
    Aug 3, 2018 at 14:05
  • $\begingroup$ @DuttA I would hazard a guess that the OP has not normalised the inputs. $\endgroup$ Aug 3, 2018 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .