MCPcopy Create free account
hub / github.com/pytorch/pytorch / epoch_limiter

Function epoch_limiter

caffe2/python/checkpoint.py:819–833  ·  view source on GitHub ↗

Creates a task that will output True when a given number of epochs has finished.

(job, num_epochs)

Source from the content-addressed store, hash-verified

817
818
819def 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)

Callers 1

Calls 4

TaskClass · 0.90
NetMethod · 0.80
add_stop_conditionMethod · 0.80
outputsMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…