raul:

conf_matrix = confusion_matrix(pred_arr, Y_train)


Seems alright to me!
It could be useful to you to navigate through the official tutorials 2 to get a better grasp of PyTorch’s features. Some other useful resources could be PyTorch Examples and FastAI MOOC.