Just remove the print statement inside confusion_matrix.
Currently each call also print the current stats.
If you just want to print it at the end, past the print statements at the desired place (e.g. after the training loop).
Also, it looks like you are computing the training and validation stats together, which is a bad idea. Usually you would re-create the confusion matrix for each dataset.