fix backtracking when losses stay at inf (fixes #2206) (#2209)

* fix backtracking when losses stay at inf

* always backtrack when there is an inf value
This commit is contained in:
Adrià Arrufat 2020-10-14 21:17:30 +09:00 committed by GitHub
parent a1f158379e
commit 5074850356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1113,10 +1113,10 @@ namespace dlib
while (previous_loss_values_to_keep_until_disk_sync.size() > 2 * gradient_updates_since_last_sync)
previous_loss_values_to_keep_until_disk_sync.pop_front();
// Always retry if there are any nan values
// Always retry if there are any nan or inf values
for (auto x : previous_loss_values_to_keep_until_disk_sync)
{
if (std::isnan(x))
if (std::isnan(x) || std::isinf(x))
return true;
}