Do snapshot after computing loss and test accuracy

Rearranged the code to do the snapshot after computing the loss and the test accuracy.