+ model.main_test_accuracy = 0.0
+ model.id = k
+
+ models.append(model)
+
+
+nb_parameters = sum(p.numel() for p in models[0].parameters())
+log_string(f"nb_parameters {nb_parameters} ({int(nb_parameters/1e6)}M)")
+
+######################################################################
+
+for n_epoch in range(args.nb_epochs):
+ log_string(f"--- epoch {n_epoch} ----------------------------------------")
+
+ cta = " ".join([f"{float(m.main_test_accuracy):.04f}" for m in models])
+ log_string(f"current_test_accuracies {cta}")
+
+ # Select, improve, and eval the worst model
+
+ weakest_model = min(models, key=lambda m: float(m.main_test_accuracy))
+
+ log_string(
+ f"training model {weakest_model.id} main_test_accuracy {weakest_model.main_test_accuracy}"
+ )
+
+ one_epoch(weakest_model, quizz_machine)
+
+ log_string(
+ f"train_set_composition w_quizzes {quizz_machine.nb_batch_w_quizzes} c_quizzes {quizz_machine.nb_batch_c_quizzes}"
+ )
+
+ run_tests(weakest_model, quizz_machine, deterministic_synthesis=False)
+
+ log_string(
+ f"test_set_composition w_quizzes {quizz_machine.nb_batch_w_quizzes} c_quizzes {quizz_machine.nb_batch_c_quizzes}"
+ )
+
+ # Replace a fraction of the w_quizzes with fresh ones
+
+ quizz_machine.renew_w_quizzes(args.nb_train_samples // args.nb_gpts)
+
+ # If all the models are good enough, generate new quizzes and
+ # re-compute the test errors
+
+ if min([m.main_test_accuracy for m in models]) >= args.accuracy_to_make_c_quizzes:
+ create_c_quizzes(
+ models,
+ quizz_machine,
+ nb_for_train=nb_new_c_quizzes_for_train,
+ nb_for_test=nb_new_c_quizzes_for_test,
+ )
+
+ for model in models:
+ run_tests(model, quizz_machine, deterministic_synthesis=False)