Training for HMM part2.