Here is a sample neural net using tensorflow,
x = tf.keras.layers.Input((None,))
x = tf.keras.layers.Dense(100)(x)
x1 = tf.keras.layers.Dense(1)(x)
model = tf.keras.Model(inputs=x, outputs=x1)
model.compile("adam", loss=tf.keras.losses.BinaryCrossentropy(from_logits=True))
model.fit(x, y)
Am I using from_logits correctly in binary loss? or should I change my output layer to,
x1 = tf.keras.layers.Dense(1, activation="sigmoid")
Can anyone clear this confusion?
I have tried the below model without from_logits in loss function, and I was getting good results, but if I use from_logits then not getting good results.
x = tf.keras.layers.Input((None,))
x = tf.keras.layers.Dense(100)(x)
x1 = tf.keras.layers.Dense(1)(x)
model = tf.keras.Model(inputs=x, outputs=x1)
model.compile("adam", loss=tf.keras.losses.BinaryCrossentropy())
model.fit(x, y)