Revert some of the earlier change

This commit is contained in:
Juha Reunanen 2019-11-08 12:32:42 +02:00
parent 2b6dbff8bb
commit 6c852124ef
1 changed files with 4 additions and 7 deletions

View File

@ -1068,18 +1068,15 @@ namespace dlib
return true;
}
// if we haven't seen much data yet then just say false.
if (gradient_updates_since_last_sync < 30)
// if we haven't seen much data yet then just say false. Or, alternatively, if
// it's been too long since the last sync then don't reload either.
if (gradient_updates_since_last_sync < 30 || previous_loss_values.size() < 2*gradient_updates_since_last_sync)
return false;
// Now look at the data since a little before the last disk sync. We will
// check if the loss is getting better or worse.
running_gradient g;
const size_t first_index
= previous_loss_values.size() < 2 * gradient_updates_since_last_sync
? 0
: previous_loss_values.size() - 2 * gradient_updates_since_last_sync;
for (size_t i = first_index; i < previous_loss_values.size(); ++i)
for (size_t i = previous_loss_values.size() - 2*gradient_updates_since_last_sync; i < previous_loss_values.size(); ++i)
g.add(previous_loss_values[i]);
// if the loss is very likely to be increasing then return true