update train.py using mstephenmsmith's submission code snippet