5

I need to classify images as either cancerous or not cancerous.

For this, I built a classical CNN but I am hesitating between labeling my dataset with either two-column vector like this:

cancerous: [0, 1]
not cancerous: [1, 0]

and using a softmax activation function with 2 output neurons.

model.add(Dense(2, activation='softmax'))

OR

cancerous: [1]
not cancerous: [0]

and using a sigmoid activation function with one output neuron.

model.add(Dense(1, activation='sigmoid'))

Which model is better given that I need to use the probability of having cancer as final metric for the patient and also for plotting the ROC curve?

Boels Maxence
  • 349
  • 3
  • 16
  • 1
    This question was asked and answered in detail [here](https://stats.stackexchange.com/questions/207049/neural-network-for-binary-classification-use-1-or-2-output-neurons). It doesn't talk about ROC, but you might stilll find it useful. – sid_508 Apr 08 '20 at 08:27
  • Using sigmoid or softmax activations is directly linked to use binary or one-hot encoded labels, you should be completely aware of that, as you made an incorrect comment on a deleted answer. – Dr. Snoopy Apr 08 '20 at 08:40

1 Answers1

3

The general tendency is to use multiple output nodes with sigmoid curve for multi-label classification. Often, a softmax is used for multiclass classification, where softmax predicts the probabilities of each output and we choose class with highest probability. For binary classification, we can choose a single neuron output passed through sigmoid, and then set a threshold to choose the class, or use two neuron output and then perform a softmax. In either of the cases, thresholding is possible.It is rather easy to plot a ROC curve with single neuron output, as you'll have to threshold over one value. So, you can easily go with model.add(Dense(1, activation='sigmoid'))

Ashwin Geet D'Sa
  • 6,346
  • 2
  • 31
  • 59