input: iterator return: (item, is_last_batch)
(it)
| 65 | |
| 66 | |
| 67 | def check_last_batch(it): |
| 68 | ''' |
| 69 | input: iterator |
| 70 | return: (item, is_last_batch) |
| 71 | ''' |
| 72 | last = None |
| 73 | for x in it: |
| 74 | if last is not None: |
| 75 | yield last, False |
| 76 | last = x |
| 77 | if last is not None: |
| 78 | yield last, True |
| 79 | |
| 80 | |
| 81 | NAN_LOSS_CNT = 0 |