We calculate the accuracy of our model as follows:
- The y_hat parameter denotes the predicted probability for each class of our model. Since we have 10 classes, we will have 10 probabilities. If the probability is high at position 7, then it means that our network predicts the input image as digit 7 with high probability. The tf.argmax() function returns the index of the largest value. Thus, tf.argmax(y_hat,1) gives the index where the probability is high. Thus, if the probability is high at index 7, then it returns 7.
- The Y parameter denotes the actual labels, and they are the one-hot encoded values. That is, it consists of zeros everywhere except at the position of the actual image, where it consists of 1. For instance, ...