adding assert to ensure the computation of training is correct