Aarya:

denominator (total) gets bigger and bigger leading the accuracy in one digit as the training progresses.


So that step does seem to have solved your original problem?



 Aarya:

I have more than 100 % training accuracy at the end of each epoch.


Edited to add:
Could you tell me the following? What is happening in the line



 Aarya:

metric.total = (batch_idx+1)*y_true_2.shape[0]


?