Creates a task that will output True when a given number of epochs has finished.
(job, num_epochs)
| 817 | |
| 818 | |
| 819 | def epoch_limiter(job, num_epochs): |
| 820 | """ |
| 821 | Creates a task that will output True when a given |
| 822 | number of epochs has finished. |
| 823 | """ |
| 824 | with job.init_group: |
| 825 | init_net = core.Net('epoch_counter_init') |
| 826 | counter = init_net.CreateCounter([], init_count=num_epochs - 1) |
| 827 | Task(step=init_net) |
| 828 | |
| 829 | with job.epoch_group: |
| 830 | epoch_net = core.Net('epoch_countdown') |
| 831 | finished = epoch_net.CountDown(counter) |
| 832 | output = Task(step=epoch_net, outputs=finished).outputs()[0] |
| 833 | job.add_stop_condition(output) |
searching dependent graphs…