Prevent schedule from crashing close to the end of training #3335
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The check introduced in #2792 is not strong enough.
In fastai/fastbook#263 it was noted that sometimes in
fastai/callback/schedule.py
the lines:can lead to index-out-of-range errors when
pos
is very close to the final value ofpcts
(as can occur near the end of training usinglearner.fit_one_cycle()
when the total number of steps is very large).The following check against this was introduced in #2792:
But it looks like the error can still sneak through in some cases, check out the following:
This is my first contribution so I'm trying to keep this PR minimal. Initially I strengthened the check to
but by then it seemed like the checks were getting a little out of hand.
Very happy to hear feedback/make changes.
Probably a good idea to get this one in kind of soon if possible, since it's been cropping up on the forms a little recently, e.g.: IndexError: index 3 is out of bounds for dimension 0 with size 3