Keras: How to get each sample loss of batch

Created on 6 Oct 2016  路  5Comments  路  Source: keras-team/keras

Is it possible to log the each batch sample loss during batch processing and get the loss list in on_batch_end(), as it returns total loss?

something like

[sample id1-loss_val, sample],[sample-id2,loss-val2]......

stale

Most helpful comment

I would like to upvote this issue as I (as well as some others) need such information for active learning setup.

Thanks!

All 5 comments

You can do that using the callbacks by writing your own as given in the documentation.


class LossHistory(keras.callbacks.Callback):

def on_train_begin(self, logs={}):
self.losses = []

def on_batch_end(self, batch, logs={}):
self.losses.append(logs.get('loss'))

@AdityaGudimella It looks like your snippet gives the batch loss, not the sample loss, right?

@gaurav-kjain @AdityaGudimella ping
Any solutions for this problem?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

I would like to upvote this issue as I (as well as some others) need such information for active learning setup.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings