Skip to content

Instantly share code, notes, and snippets.

@manashmandal
Created February 18, 2018 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manashmandal/9d11e269f6ba04986cf844d62ead466b to your computer and use it in GitHub Desktop.
Save manashmandal/9d11e269f6ba04986cf844d62ead466b to your computer and use it in GitHub Desktop.
import keras.backend as K
def multitask_loss(y_true, y_pred):
# Avoid divide by 0
y_pred = K.clip(y_pred, K.epsilon(), 1 - K.epsilon())
# Multi-task loss
return K.mean(K.sum(- y_true * K.log(y_pred) - (1 - y_true) * K.log(1 - y_pred), axis=1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment