Fixed bug in generate training