]
-# ----- test
-
-# ranked_models = sorted(models, key=lambda m: float(m.test_accuracy))
-# weakest_models = ranked_models[: len(gpus)]
-
-# n_epoch = 14
-
######################################################################
for n_epoch in range(current_epoch, args.nb_epochs):
[(models, nb_c_quizzes_to_generate, gpu) for gpu in gpus],
)
- ## records, threads = [], []
- ##
- ## start_time = time.perf_counter()
- ##
- ## if len(gpus) > 1:
- ## for gpu in gpus:
- ## t = threading.Thread(
- ## target=thread_generate_ae_c_quizzes,
- ## daemon=True,
- ## args=(models, nb_c_quizzes_to_generate, records, gpu),
- ## )
- ##
- ## # To get a different sequence between threads
- ## log_string(f"dummy {torch.rand(1)}")
- ## threads.append(t)
- ## t.start()
- ##
- ## for t in threads:
- ## t.join()
- ##
- ## else:
- ## records.append(
- ## generate_ae_c_quizzes(models, nb_c_quizzes_to_generate, gpus[0])
- ## )
- ##
- ## time_c_quizzes = int(time.perf_counter() - start_time)
- ##
- ## c_quizzes = torch.cat([q.to(main_device) for q, _ in records], dim=0)
- ## agreements = torch.cat([a.to(main_device) for _, a in records], dim=0)
-
# --------------------------------------------------------------------
filename = f"culture_c_quiz_{n_epoch:04d}.png"
else:
log_string(f"nb_c_quizzes {c_quizzes.size(0)}")
- # one_ae_epoch(model, quiz_machine, n_epoch, None)
- # exit(0)
-
# --------------------------------------------------------------------
ranked_models = sorted(models, key=lambda m: float(m.test_accuracy))
],
)
- ## threads = []
- ##
- ## start_time = time.perf_counter()
- ##
- ## if len(gpus) > 1:
- ## for gpu, model in zip(gpus, weakest_models):
- ## log_string(f"training model {model.id} (accuracy {model.test_accuracy})")
- ## if c_quizzes is None:
- ## c_quizzes_for_this_model = None
- ## else:
- ## c_quizzes_for_this_model = c_quizzes[agreements[:, model.id]]
- ##
- ## t = threading.Thread(
- ## target=one_ae_epoch,
- ## daemon=True,
- ## args=(model, quiz_machine, n_epoch, c_quizzes_for_this_model, gpu),
- ## )
- ##
- ## threads.append(t)
- ##
- ## t.start()
- ##
- ## for t in threads:
- ## t.join()
- ##
- ## else:
- ## model = weakest_models[0]
- ## log_string(f"training model {model.id} (accuracy {model.test_accuracy})")
- ## if c_quizzes is None:
- ## c_quizzes_for_this_model = None
- ## else:
- ## c_quizzes_for_this_model = c_quizzes[agreements[:, model.id]]
- ##
- ## one_ae_epoch(model, quiz_machine, n_epoch, c_quizzes_for_this_model, gpus[0])
-
time_train += int(time.perf_counter() - start_time)
# --------------------------------------------------------------------