Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I'm trying to re-implement Neural Networks in Python. I implemented the cost function and the backpropagation algorithm correctly. I have checked them by executing its Octave equivalent code.

But when I'm trying to use the scipy.optimize.fmin_cg function, the iterations take a very long time to execute. It exits with a warning and gives me an error saying that the "desired error rate wasn't achieved".

The same program in Octave executes fine. However, it has its own fmincg function defined.

What am I doing wrong?

share|improve this question
add comment

1 Answer

As a future hint, use the double question mark ?? to pull the source of the function:

Looking at the scipy sources this error message comes up if the internal parameter alpha_k is zero or None.

This value in turn is tied to the internal Wolfe Line search algorithm. In particular it is called when the search doesn't find a better value along the search trajectory. Your function likely has a linear contour somewhere along it that the optimizer falls into and gets confused.

Perhaps try adding a callback, and see where the failing search is generated?

share|improve this answer
    
As a follow up to this, scipy picks its max iteration count based on the size of the vector to be optimized. This is a better than average guess, but ought to be documented more obviously. –  meawoppl Jan 15 at 0:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.