Fix find_max() going into an infinite loop in some cases when a non-differentiable function is given.

This commit is contained in:
Davis King 2019-10-31 20:23:15 -04:00
parent 1eccfbc99a
commit bd6dcc0b49
1 changed files with 4 additions and 0 deletions

View File

@ -272,6 +272,10 @@ namespace dlib
throw error("The objective function generated non-finite outputs");
if (!is_finite(g))
throw error("The objective function generated non-finite outputs");
// Gradient is zero, no more progress is possible. So stop.
if (alpha == 0)
break;
}
return -f_value;