Could we have an on_epoch_begin() function in utils.Sequence?

There is already a on_epoch_end(), but I can see a use case for the begin equivalent:

Let's say I have a data generator that has a fixed internal set of data and maybe does some augmentation. If I want to ensure that all patches have been used in an epoch (say, for debugging reasons), I would add a count variable to the generator, set it to 0 on on_epoch_begin(), increment it on __getitem__() and check against my internal data size on on_epoch_end().

I could achieve this currently by setting count to 0 on on_epoch_end(), but this won't work, because keras may call __getitem__() before the first epoch actually starts (e.g. for internal preprocessing).

So the workaround that I currently use is to create a callback object, whose on_epoch_begin() calls a reset() function I put in my generator object. It's ugly, but works.

It would be much nicer to have a proper on_epoch_begin()

Comment From: fchollet

It is certainly feasible. It would need to get added not just in PyDataset, but also in DataAdapter and then called in EpochIterator as well as all EpochIterator subclasses that are backend-specific. Are you able to open a PR for this feature?

Comment From: github-actions[bot]

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

Comment From: github-actions[bot]

This issue is stale because it has been open for 180 days with no activity. It will be closed if no further activity occurs. Thank you.

Comment From: sonali-kumari1

Hi @Cerno-b -

Since the PR has fixed this issue and has already been merged, please feel free to close this issue. Thanks!

Comment From: github-actions[bot]

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

Comment From: github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.