Keras: Getting NotImplementedError for "on_epoch_end" while training using fit_generator on a Sequence object

Created on 13 Sep 2017  路  7Comments  路  Source: keras-team/keras

Exception in thread Thread-8:
Traceback (most recent call last):
File "/users/gpu/rohitg1/miniconda2/envs/tensorflow/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/users/gpu/rohitg1/miniconda2/envs/tensorflow/lib/python2.7/threading.py", line 754, in run
self.__target(self.__args, *self.__kwargs)
File "/users/gpu/rohitg1/.local/lib/python2.7/site-packages/keras/utils/data_utils.py", line 492, in _run
self.sequence.on_epoch_end()
File "/users/gpu/rohitg1/.local/lib/python2.7/site-packages/keras/utils/data_utils.py", line 358, in on_epoch_end
raise NotImplementedError
NotImplementedError

I am trying to train a Video classification model. Gist for portion of code is available here:

https://gist.github.com/rohit-gupta/7668b79389e29598ace41813fc1a50d2

Do I need to implement a "on_epoch_end" function in my Sequence object to get this o work ?

Most helpful comment

yes you need to,
You can do it as simple as :

def on_epoch_end(self):
        pass

@joeyearsley Should we make it optional or clarify the doc instead to avoid issues for newcomers?

All 7 comments

yes you need to,
You can do it as simple as :

def on_epoch_end(self):
        pass

@joeyearsley Should we make it optional or clarify the doc instead to avoid issues for newcomers?

I'ld say optional as it isn't always needed

@Dref360 Thanks for your reply, Its solved my issue ! Though I am curious as to what the purpose of this is ? What do people usually implement in this function ?

If you want to shuffle your data between epoch, on_epoch_end is called at this time.

Had to read keras' code to figure out why my script was raising this NotImplementedError. This should definitely be documented or made optional asap

Seems fixed with PR #8007

Yes, it is fixed at master.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

braingineer picture braingineer  路  3Comments

NancyZxll picture NancyZxll  路  3Comments

zygmuntz picture zygmuntz  路  3Comments

oweingrod picture oweingrod  路  3Comments

harishkrishnav picture harishkrishnav  路  3Comments