I've been using Keras for binary classification with Tensorflow backend in Python. My model is created like this :
model = Sequential()
model.add(Dense(1000, input_dim=168319))
model.add(Dense(units=1, activation='sigmoid'))
model.compile(loss="binary_crossentropy",
optimizer="adam",
metrics=['accuracy'])
And my result after training looks like this :
342/1342 [==============================] - 79s 59ms/step - loss: 0.0586 - acc: 0.9911 - val_loss: 0.4632 - val_acc: 0.8169
If I use my network to predict a sample, it gives me a number between [0,1], as it should, since I'm using a sigmoid activation function for my output neuron. One example of what my output looks like after a prediction for 6 samples which should be of class 1 :
[[1. ][1. ][0.99997437][0.18694757][0.18712251][0.9491884 ]]
Since the results are all floats between 0 and 1 , I've been wondering how Keras calculates the validation accuracy. Validation accuracy is measured with testing samples that are not used for training. As mentioned here how does Keras compute validation accuracy and training accuracy?, the validation accuracy is calculated with (amount of correct guesses)/(total amount of guesses)
.
My Question here is, how does Keras decide which class the guess belongs to, when is it "correct". Does it round up at 0.5? Or is everything between 0 and 1 classified as "wrong guess" (Would expect a way lower number in validation accuracy then)?