MATLAB: Does the neural network enter into an infinite loop during Levenberg-Marquardt training when using the Neural Network Toolbox 4.0 (R12)

Deep Learning Toolboxinfinitelevenbergloopmarquardtneuraltrainlm

I created a neural network and set its "trainFcn" property to "Levenberg-Marquardt". When I train the network, training becomes stuck on one epoch indefinitely.

Best Answer

This is a bug the way the TRAINLM function updates the step size in the Neural Networks Toolbox 4.0 (R12) . This has been fixed in version 4.0.2 (R13) of the Neural Networks Toolbox.
To fix the problem in previous releases, change lines 323 through 326 in
$MATLABROOT\toolbox\nnet\nnet\trainlm.m,
where $MATLABROOT is your root MATLAB directory, from the following:
break;
if (mu < 1e-20)
mu = 1e-20;
end
to this:
if (mu < 1e-20)
mu = 1e-20;
end
break