I'm trying to train a binary classifier with Keras. This is my model:
model = Sequential()
model.add(Dense(DENSE_DIM, activation='relu', input_shape=(data_shape[1:])))
#model.add(Dropout(0.3))
model.add(Dense(target_len, activation='softmax'))
model.summary()
adam = Adam(lr=learning_rate)
model.compile(loss='binary_crossentropy', optimizer=adam, metrics=['binary_accuracy'])
I train the model with the following line:
model.fit(train, train_target, epochs=num_epochs, batch_size=batch_size, class_weight=weights, validation_data=(dev,dev_target))
I've removed the dropout from the hidden layer to the output layer and I have already checked the input and it is the same every time I run the model. Still I am getting slightly different accuracy and f1 measures:
TrainsetLen:(1231, 865) #EPOCH: (50, 'bert', 0.001, 64) AVG: 0.7047619047619048 F1: 0.693599566738888
TrainsetLen:(1231, 865) #EPOCH: (50, 'bert', 0.001, 64) AVG: 0.7180952380952381 F1: 0.7101035060334213
This is how I compute them:
fold_acc = accuracy_score(test_target, test_preds)
fold_f1 = f1_score(test_target, test_preds, average='macro')
print("Test Accuracy on fold "+str(fold)+": ",fold_acc)
print("Test F1 on fold "+str(fold)+": ",fold_f1)
avg_acc += fold_acc/num_folds
avg_f1 += fold_f1/num_folds
the order of the folds is also the same. Shouldn't I be getting consistent results? What can be causing inconsistency on my model?
Thanks for your time and attention, Lucas.