optimize calculation of current_jobs

This commit is contained in:
hroff-1902 2020-03-03 01:20:14 +03:00 committed by GitHub
parent 92425642da
commit a7d4755859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -576,10 +576,12 @@ class Hyperopt:
f_val = self.run_optimizer_parallel(parallel, asked, i) f_val = self.run_optimizer_parallel(parallel, asked, i)
self.opt.tell(asked, [v['loss'] for v in f_val]) self.opt.tell(asked, [v['loss'] for v in f_val])
self.fix_optimizer_models_list() self.fix_optimizer_models_list()
if (i * jobs + jobs) > self.total_epochs:
current_jobs = jobs - ((i * jobs + jobs) - self.total_epochs) # Correct the number of epochs to handled for the last
else: # iteration (should not exceed self.total_epochs)
current_jobs = jobs n_rest = (i + 1) * jobs - self.total_epochs
current_jobs = jobs - n_rest if n_rest > 0 else jobs
for j in range(current_jobs): for j in range(current_jobs):
# Use human-friendly indexes here (starting from 1) # Use human-friendly indexes here (starting from 1)
current = i * jobs + j + 1 current = i * jobs + j + 1