add code from LiuRujia's TrainningGuide