Fix bug in calculating training data length.