1

I'm trying to do binary classification using sigmoid and binary cross-entrophy. The dataset used is also balanced. But the F1 score for positive class is 0.

from keras.losses import binary_crossentropy

dense_net = DenseNet121(weights='imagenet', include_top=False, input_shape=(224, 224, 3))

for layer in dense_net.layers:
    layer.trainable = False

base_model = Sequential()
base_model.add(dense_net)
base_model.add(Dense(units=8, activation= 'relu'))
base_model.add(Dropout(0.5))
base_model.add(Flatten())
base_model.add(Dense(1, activation='sigmoid', name='output'))

model1 = base_model

# model compile
model1.compile(optimizer=Adam(), loss='binary_crossentropy', metrics=['accuracy'])`

I tried using flatten() as suggested in this StackOverflow question but it doesn't work for the positive class, it is still 0. Please find the classification report in this link.

I would be very glad if you could provide me some help on this.

0 Answers0