2
$\begingroup$

I use a Keras EfficientNetB7 and transfer learning to solve a binary classification problem. I use tf.keras.layers.Dense(1, activation="sigmoid")(x) for my final layer.

My labels are encoded as the following for the model.fit():

[[1.]
 [1.]
 [0.]
 [1.]
  ...
 [1.]
 [1.]
 [0.]]

My question is about the output of the model.predict(). For example, if the output is [[0.09122807]], does this mean that the prediction is class 1. or 0.?

Initially, I assumed it would have been class 0. but my model predicts the opposite of this assumption. In some stackoverflow posts, I saw that the output should be used 1 - p where p is the probability of class 1.

There is conflicting information on the net; hence, wanted to ask your guidance.

$\endgroup$
1
  • $\begingroup$ It is nearer to 0 than 1 which means the result label is 0. $\endgroup$ Commented Jan 2 at 5:12

1 Answer 1

3
$\begingroup$

If you are using binary cross-entropy as loss function, the output of Sigmoid functions represent the probability of $\mathbb{P}[y=1]$. Hence, it means that $\mathbb{P}[y=0] = 1 - \mathbb{P}[y=1]$. Therefore, when the output is $0.09$, it means that the prediction is $y=0$ as it is more probable ($1-0.09 = 0.91$).

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .