In Lesson 1 code, at the beginning we have the first run of the model with this code:
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=True)
I wanted to see the confusion matrix after running this first code, so I used the confusion matrix code towards the end of lesson one and copied it over like this, just after the above code:
log_preds,y = learn.TTA() probs = np.mean(np.exp(log_preds),0) preds = np.argmax(probs, axis=1) probs = probs[:,1] from sklearn.metrics import confusion_matrix cm = confusion_matrix(y, preds) plot_confusion_matrix(cm, data.classes)
It seems to work, at least there are no error messages, but is this correct ?