title: Implement custom loss function in Tensorflow 2.0
body: <p>I'm building a model for Time series classification. The data is very unbalanced so I've decided to use a weighted cross entropy function as my loss. </p>
  
  <p>Tensorflow provides <a href="https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/weighted_cross_entropy_with_logits" rel="noreferrer">tf.nn.weighted_cross_entropy_with_logits</a> but I'm not sure how to use it in TF 2.0. Because my model is build using tf.keras API I was thinking about creating my custom loss function like this:</p>
  
  <pre><code>pos_weight=10
  def weighted_cross_entropy_with_logits(y_true,y_pred):
    return tf.nn.weighted_cross_entropy_with_logits(y_true,y_pred,pos_weight)
  
  # .....
  model.compile(loss=weighted_cross_entropy_with_logits,optimizer="adam",metrics=["acc"])
  </code></pre>
  
  <p>My question is: is there a way to use tf.nn.weighted_cross_entropy_with_logits with tf.keras API directly?</p>