Skip to content Skip to sidebar Skip to footer

Implement Custom Cost Function In Keras Which Requires Output Of Whole Batch-size

Brief info about the data-set:- Its a person Re-ID problem(whether 2 images are same or not) and i have to write my own loss/cost function(binomial Deviance) for its implementatio

Solution 1:

Define your custom loss with an additional batch_size argument:

defmy_loss_template(y_true, y_pred, batch_size):
    # compute the loss

To use it,

batch_size = 20
my_loss = lambda x, y: my_loss_template(x, y, batch_size)
model.compile(optimizer='adam', loss=my_loss)

Post a Comment for "Implement Custom Cost Function In Keras Which Requires Output Of Whole Batch-size"