The training/evaluation mode is switched via model.train() and model.eval(); The affine argument does not have anything to do with training vs. evaluation mode determination. Affine just flags wether to apply affine transformation or not.