Sorry for delayed response, I was out.
the code line
take the average of correct predictions to get the accuracy, you are checking average of predictions where it mentions you to take average of correct predictions.
so you mentioning just y_pred would be incorrect.
rather take tf.cast(when y pred is absolute equal to your actual targets, datatype)
here is a similar threads