Useful Lines of Code for Validation - Gatecrashah/Image-Recognition GitHub Wiki

# Validate Predictions Keras' fit() function conveniently shows us the value of the loss function, and the accuracy, after every epoch ("epoch" refers to one full run through all training examples). The most important metrics for us to look at are for the validation set, since we want to check for over-fitting. Tip: with our first model we should try to overfit before we start worrying about how to reduce over-fitting - there's no point even thinking about regularization, data augmentation, etc if you're still under-fitting! (We'll be looking at these techniques shortly).

As well as looking at the overall metrics, it's also a good idea to look at examples of each of:

  1. A few correct labels at random
  2. A few incorrect labels at random
  3. The most correct labels of each class (ie those with highest probability that are correct)
  4. The most incorrect labels of each class (ie those with highest probability that are incorrect)
  5. The most uncertain labels (ie those with probability closest to 0.5).

#1. A few correct labels at random correct = np.where(our_labels==expected_labels)[0] print "Found %d correct labels" % len(correct) idx = permutation(correct)[:n_view] plots_idx(idx, our_predictions[idx])

#2. A few incorrect labels at random incorrect = np.where(our_labels!=expected_labels)[0] print "Found %d incorrect labels" % len(incorrect) idx = permutation(incorrect)[:n_view] plots_idx(idx, our_predictions[idx])