Fix epoch & batch end bug.