Nanobit glenn-jocher commited on
Commit
fb4fc8c
·
unverified ·
1 Parent(s): da35727

Fix ema attribute error in DDP mode (#775)

Browse files

* Fix ema error in DDP mode

* Update train.py

Co-authored-by: Glenn Jocher <[email protected]>

Files changed (1) hide show
  1. train.py +1 -1
train.py CHANGED
@@ -164,11 +164,11 @@ def train(hyp, opt, device, tb_writer=None):
164
  world_size=opt.world_size, workers=opt.workers)
165
  mlc = np.concatenate(dataset.labels, 0)[:, 0].max() # max label class
166
  nb = len(dataloader) # number of batches
167
- ema.updates = start_epoch * nb // accumulate # set EMA updates
168
  assert mlc < nc, 'Label class %g exceeds nc=%g in %s. Possible class labels are 0-%g' % (mlc, nc, opt.data, nc - 1)
169
 
170
  # Testloader
171
  if rank in [-1, 0]:
 
172
  testloader = create_dataloader(test_path, imgsz_test, total_batch_size, gs, opt,
173
  hyp=hyp, augment=False, cache=opt.cache_images, rect=True, rank=-1,
174
  world_size=opt.world_size, workers=opt.workers)[0] # only runs on process 0
 
164
  world_size=opt.world_size, workers=opt.workers)
165
  mlc = np.concatenate(dataset.labels, 0)[:, 0].max() # max label class
166
  nb = len(dataloader) # number of batches
 
167
  assert mlc < nc, 'Label class %g exceeds nc=%g in %s. Possible class labels are 0-%g' % (mlc, nc, opt.data, nc - 1)
168
 
169
  # Testloader
170
  if rank in [-1, 0]:
171
+ ema.updates = start_epoch * nb // accumulate # set EMA updates
172
  testloader = create_dataloader(test_path, imgsz_test, total_batch_size, gs, opt,
173
  hyp=hyp, augment=False, cache=opt.cache_images, rect=True, rank=-1,
174
  world_size=opt.world_size, workers=opt.workers)[0] # only runs on process 0