Sunday 24 February 2019

How can I specify a loss function in Keras while setting a parameter?

My understanding is that keras requires loss functions to have the signature:

def custom_loss(y_true, y_pred):

I am trying to use sklearn.metrics.cohen_kappa_score, which takes (y1, y2, labels=None, weights=None, sample_weight=None)`

If I use it as is:

model.compile(loss=metrics.cohen_kappa_score,
              optimizer='adam', metrics=['accuracy'])

Then the weights won't be set. I want to set that to quadtratic. Is there some what to pass this through?



from How can I specify a loss function in Keras while setting a parameter?

No comments:

Post a Comment