-1

for two class classification problem sigmoid + binary_crossentropy is fine or softmax + categorical_crossentropy is fine. But in my case I have used softmax(2 dense layers) + binary_crossentropy and trained a DL model.. Is this correct? Does the accuracy produced is genuine?

Please let me know if softmax(2 dense layers) + binary_crossentropy is correct or not.

1 Answers1

0

The number of layers it's irrelevant at this stage. If you use softmax then it's either categorical_crossentropy or sparse_categorical_crossentropy depending whether you one-hot-encoded the targets or not. But there's no consistency between softmax output layer activation function and loss='binary_crossentropy' , output is likely to be whacky.

model.add(Dense(2, activation='softmax')) #2 because it's a two class problem

model.compile(loss='categorical_crossentropy', 
              optimizer='adagrad', #optimizer can be whatever works best
              metrics=['accuracy'])

Whether using softmax or sigmoid depends on your classification problem. Is it something like 'A vs NOT A' or 'A or B' . Plot the model performance, compare and drive conclusions.

cla.cif
  • 1
  • 1
  • 6