MCPcopy Create free account
hub / github.com/NVlabs/SPADE / __init__

Method __init__

util/iter_counter.py:13–30  ·  view source on GitHub ↗
(self, opt, dataset_size)

Source from the content-addressed store, hash-verified

11# Helper class that keeps track of training iterations
12class IterationCounter():
13 def __init__(self, opt, dataset_size):
14 self.opt = opt
15 self.dataset_size = dataset_size
16
17 self.first_epoch = 1
18 self.total_epochs = opt.niter + opt.niter_decay
19 self.epoch_iter = 0 # iter number within each epoch
20 self.iter_record_path = os.path.join(self.opt.checkpoints_dir, self.opt.name, 'iter.txt')
21 if opt.isTrain and opt.continue_train:
22 try:
23 self.first_epoch, self.epoch_iter = np.loadtxt(
24 self.iter_record_path, delimiter=',', dtype=int)
25 print('Resuming from epoch %d at iteration %d' % (self.first_epoch, self.epoch_iter))
26 except:
27 print('Could not load iteration record at %s. Starting from beginning.' %
28 self.iter_record_path)
29
30 self.total_steps_so_far = (self.first_epoch - 1) * dataset_size + self.epoch_iter
31
32 # return the iterator of epochs for the training
33 def training_epochs(self):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected