Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. def custom_loss(data, y_pred):
  2.  
  3. y_true = data[:, 0]
  4. d = data[:, 1:]
  5. # condition
  6. mask2 = keras.backend.not_equal(y_true, 0) #i.e. y_true != 0
  7. mask2 = KB.cast(mask2, KB.floatx())
  8. # returns 0 when y_true =0, 1 otherwise
  9. #calculate loss using d...
  10. loss_value = 2 * d * y_pred + mask2 * (2 * d * y_true * KB.log(y_true) + 2 * d * y_true * KB.log(y_pred) - 2 * d * y_true)
  11. return loss_value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement