title: Difference about "BinaryCrossentropy" and "binary_crossentropy" in tf.keras.losses?
body: <p>I'm training a model  using TensorFlow 2.0 using tf.GradientTape(), but I find that the model's accuracy is <code>95%</code> if I use <code>tf.keras.losses.BinaryCrossentropy</code>, but degrade to <code>75%</code> if I use <code>tf.keras.losses.binary_crossentropy</code>. So I'm confused about the difference about the same metric here? </p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import tensorflow as tf
  from tensorflow.keras import layers
  
  from sklearn.model_selection import train_test_split
  
  def read_data():
      red_wine = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv", sep=";")
      white_wine = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv", sep=";")
      red_wine["type"] = 1
      white_wine["type"] = 0
      wines = red_wine.append(white_wine)
      return wines
  
  def get_x_y(df):
      x = df.iloc[:, :-1].values.astype(np.float32)
      y = df.iloc[:, -1].values.astype(np.int32)
      return x, y
  
  def build_model():
      inputs = layers.Input(shape=(12,))
      dense1 = layers.Dense(12, activation="relu", name="dense1")(inputs)
      dense2 = layers.Dense(9, activation="relu", name="dense2")(dense1)
      outputs = layers.Dense(1, activation = "sigmoid", name="outputs")(dense2)
      model = tf.keras.Model(inputs=inputs, outputs=outputs)
      return model
  
  def generate_dataset(df, batch_size=32, shuffle=True, train_or_test = "train"):
      x, y = get_x_y(df)
      ds = tf.data.Dataset.from_tensor_slices((x, y))
      if shuffle:
          ds = ds.shuffle(10000)
      if train_or_test == "train":
          ds = ds.batch(batch_size)
      else:
          ds = ds.batch(len(df))
      return ds
  
  # loss_object = tf.keras.losses.binary_crossentropy
  loss_object = tf.keras.losses.BinaryCrossentropy()
  optimizer = tf.keras.optimizers.Adam(learning_rate=0.001)
  
  def train_step(model, optimizer, x, y):
      with tf.GradientTape() as tape:
          pred = model(x, training=True)
          loss = loss_object(y, pred)
      grads = tape.gradient(loss, model.trainable_variables)
      optimizer.apply_gradients(zip(grads, model.trainable_variables))
  
  
  def train_model(model, train_ds, epochs=10):
      for epoch in range(epochs):
          print(epoch)
          for x, y in train_ds:
              train_step(model, optimizer, x, y)
  
  def main():
      data = read_data()
      train, test = train_test_split(data, test_size=0.2, random_state=23)
      train_ds = generate_dataset(train, 32, True, "train")
      test_ds = generate_dataset(test, 32, False, "test")
      model = build_model()
      train_model(model, train_ds, 10)
      model.compile(loss='binary_crossentropy',
                    optimizer='adam',
                    metrics=['accuracy']
                    )
      model.evaluate(test_ds)
  
  main()
  </code></pre>