# Post-classification after inference in deep learning models

I designed a fire detection using Deep Learning binary classification in Keras (fire vs none). It's a simple model with a few layers. In my training dataset, I included both fire and smoke, and they are both detected (all under "fire"; mostly real fires are detected though. Smoke is less accurate).

Now I need to differentiate these two in my detection results. So basically it would be 3 classes (fire, smoke, none ). One solution that came into my mind was building a binary classification model and pipeline it after the main one. So it gets the main detections as input and prints which of the two classes it belongs to.

Is there any other approaches? What are pros/cons of various approaches?

Here is my simple architecture:

def create_model():
model = Sequential()
model.add(Conv2D(32, kernel_size = (3, 3), activation='relu', input_shape=(300, 300, 3)))

return model

#....
if retrain_from_prior_model == False:
model = create_model()
else:

• I would probably also simply try to use a final softmax layer with 3 neurons for the three categories: fire, smoke, and none. – Oxbowerce Feb 13 '20 at 17:21
• Is it a problem for you to retrain your model from scratch with 3 labels? – Mathias Müller Feb 13 '20 at 17:28
• he/she would also need to change the loss function to reflect multiclass classification. – Victor Ng Feb 13 '20 at 20:52
• @Oxbowerce can you elaborate more?! Sorry kinda new to DL. – Tina J Feb 13 '20 at 21:19
• With more than 2 classes, you cannot use binary cross-entropy as the loss function: you would need to replace with sparse categorical cross-entropy. The last dense layer would need to have size 3 instead of 2. You could try methods to re-use your existing model (such as fine-tuning, pseudo rehearsal), but they are more complex than simply retraining with 3 labels. – Mathias Müller Feb 14 '20 at 6:35