TensorFlow Sigmoid activation function as output layer - value interpretation

My TensorFlow model has the following structure. It aims to solve a binary classification problem where the labels are either 0 or 1. The output layer uses a sigmoid activation function with 1 output.

model = keras.Sequential([
layers.Dense(10, activation='relu', input_shape=[len(train_dataset.keys())]),
layers.Dense(1, activation='sigmoid')
])

model.compile(loss='binary_crossentropy',
optimizer=optimizer,
metrics=[tf.keras.metrics.Precision(), tf.keras.metrics.Recall(), tf.keras.metrics.Accuracy()])


The output given is an array of dtype=float32 numbers that lie between 0 and 1.

array([[9.5879245e-01],
[3.6847022e-01],
[3.4174323e-04],
...,
[2.6283860e-03],
[3.2045375e-04],
[1.0798702e-03]], dtype=float32)


The Tensorflow tutorials state that "Using the sigmoid activation function, this value is a float between 0 and 1 and represents a probability, or confidence level". https://www.tensorflow.org/tutorials/keras/text_classification

My question is:

Do I interpret the float values from output as:

1. "How likely it belongs to the first class label - in this case class 0 is my first class label?" e.g. model.predict() yields 0.99998 and therefore has a 99% chance of belonging to my first class label (class 0) and 1% belonging to the other class (class 1).

or

1. "The closer the output from model.predict() is to 0.0 the more likely it is class 0 and the closer the output is to 1.0 the more likely it is class 1"

In short, value of model.predict() function is interpreted as mentioned in option 2.

In order to clarify, let's assume we are talking about spam detection application. Label 0 represents that text/email is not spam and label 1 represents that text/email is spam.

Suppose, after running the function model.predict(), we get value 0.9899. Then we can interpret it as:

• chance of given text/email being spam is 98.99%
• chance of given text/email not being spam is 1.01%

Usually, when we talk about a binary classification problem, we will often use labels 0 & 1 to represent the classes. So the predicted value being closer to 0 means it is more likely to fall under the class 0 (in our example class 0 represents text/email not being spam.). Likewise, if the predicted value being closer to 1 means it is more likely to fall under the class 1 (in our example class 1 represents text/email being spam.)

please check this answer and see if it helps . Somehow I feel that you are getting the predict probability rather than the prediction itself

https://stackoverflow.com/questions/40002084/how-to-output-a-prediction-in-tensorflow