# Neural network model does not converge

I am using function neuralnet in the package neuralnet to build the neural network, and I see the error:

algorithm did not converge in 1 of 1 repetition(s) within the stepmax

The neural network has 20 inputs and 1 output. The problem is, with the same data and same set of inputs, I ran linear regression or random forest without any problem. So what should I look to for debugging my problem?

You might try with increasing the rep argument. If it fails, try with increasing the stepmax argument too.

One repetition of the training is called an epoch. Usually, several epochs are needed.

• Thank you very much, @Cloud Skywalker. I increased rep to 2, but it seems to me that the neuralnet function now runs very slow, it takes more than twice of duration when rep == 1. Is it usual? – mamatv Nov 25 '15 at 14:16

The rep argument is basically how many times you train your neural network. See the answer to this question. Therefore the higher the rep, the longer it will take.

You should increase the stepmax to give your model more chances to learn/converge. Or you can increase your threshold to allow an earlier stop for convergence. Alternatively, you can adjust your model, e.g. lower the number of your hidden layers and nodes.

Increasing the stepmax value from the default 1e+05 to 1e+08 makes the algorithm take exponentially more time. E.g. 90s for stepmax=1e+05 took 4h for stepmax=1e+08!

So preferably increase first the threshold from its default = 0.01 successively to 0.1, 0.2, 0.3 etc because this doesn't affect performance.