glenn-jocher commited on
Commit
1c13e67
·
1 Parent(s): 59beae9

evolution bug fix #346

Browse files
Files changed (1) hide show
  1. train.py +6 -7
train.py CHANGED
@@ -44,7 +44,7 @@ hyp = {'optimizer': 'SGD', # ['adam', 'SGD', None] if none, default is SGD
44
 
45
  def train(hyp):
46
  print(f'Hyperparameters {hyp}')
47
- log_dir = tb_writer.log_dir # run directory
48
  wdir = str(Path(log_dir) / 'weights') + os.sep # weights directory
49
 
50
  os.makedirs(wdir, exist_ok=True)
@@ -387,7 +387,10 @@ if __name__ == '__main__':
387
  opt.weights = last if opt.resume and not opt.weights else opt.weights
388
  opt.cfg = check_file(opt.cfg) # check file
389
  opt.data = check_file(opt.data) # check file
390
- opt.hyp = check_file(opt.hyp) if opt.hyp else '' # check file
 
 
 
391
  print(opt)
392
  opt.img_size.extend([opt.img_size[-1]] * (2 - len(opt.img_size))) # extend to 2 sizes (train, test)
393
  device = torch_utils.select_device(opt.device, apex=mixed_precision, batch_size=opt.batch_size)
@@ -396,12 +399,8 @@ if __name__ == '__main__':
396
 
397
  # Train
398
  if not opt.evolve:
399
- print('Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/')
400
  tb_writer = SummaryWriter(log_dir=increment_dir('runs/exp', opt.name))
401
- if opt.hyp: # update hyps
402
- with open(opt.hyp) as f:
403
- hyp.update(yaml.load(f, Loader=yaml.FullLoader))
404
-
405
  train(hyp)
406
 
407
  # Evolve hyperparameters (optional)
 
44
 
45
  def train(hyp):
46
  print(f'Hyperparameters {hyp}')
47
+ log_dir = tb_writer.log_dir if tb_writer else 'runs/evolution' # run directory
48
  wdir = str(Path(log_dir) / 'weights') + os.sep # weights directory
49
 
50
  os.makedirs(wdir, exist_ok=True)
 
387
  opt.weights = last if opt.resume and not opt.weights else opt.weights
388
  opt.cfg = check_file(opt.cfg) # check file
389
  opt.data = check_file(opt.data) # check file
390
+ if opt.hyp: # update hyps
391
+ opt.hyp = check_file(opt.hyp) # check file
392
+ with open(opt.hyp) as f:
393
+ hyp.update(yaml.load(f, Loader=yaml.FullLoader)) # update hyps
394
  print(opt)
395
  opt.img_size.extend([opt.img_size[-1]] * (2 - len(opt.img_size))) # extend to 2 sizes (train, test)
396
  device = torch_utils.select_device(opt.device, apex=mixed_precision, batch_size=opt.batch_size)
 
399
 
400
  # Train
401
  if not opt.evolve:
 
402
  tb_writer = SummaryWriter(log_dir=increment_dir('runs/exp', opt.name))
403
+ print('Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/')
 
 
 
404
  train(hyp)
405
 
406
  # Evolve hyperparameters (optional)