I'm training a binary classifier using Keras. I want to generate the precision_score and recall_score after each epoch in order to analyze the training more in depth. On the internet I found tutorials/help, such as:
I found Accessing validation data within a custom callback which worked best for me since I'm using Keras fit_generator. It managed to compute precision and recall after each epoch. However, I think I do something wrong when creating the custom Callback. I get the following error message:
File "...\envs\keras\lib\site-packages\keras\preprocessing\image.py", line 845, in _flow_index
current_index = (self.batch_index * self.batch_size) % self.n
ZeroDivisionError: integer division or modulo by zero
My best guess is that the custom Callback inherits incorrectly from Keras.
Has anybody experienced this issue? Or do anyone know what I am missing?
UPDATE
I think I understand the error now. In Keras image.py current_index is divided by self.n. In the class named Iterator (in Keras) n is defined as
n: Integer, total number of samples in the dataset to loop over.
In other words, I understand it as that the network can't be fed with zero samples. I realized that my test set was empty (0 samples), hence the error message.
When corrected (fed the test set with data) the code worked fine :)