Update.
authorFrançois Fleuret <francois@fleuret.org>
Sat, 6 Jul 2024 13:47:57 +0000 (16:47 +0300)
committerFrançois Fleuret <francois@fleuret.org>
Sat, 6 Jul 2024 13:47:57 +0000 (16:47 +0300)
main.py
quiz_machine.py

diff --git a/main.py b/main.py
index 6b46fa0..a2a771f 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -19,11 +19,6 @@ import sky, grids, quiz_machine
 
 ######################################################################
 
-nb_new_c_quizzes_for_train = 1000
-nb_new_c_quizzes_for_test = 100
-
-######################################################################
-
 if torch.cuda.is_available():
     device = torch.device("cuda")
     torch.backends.cuda.matmul.allow_tf32 = True
@@ -124,14 +119,6 @@ if args.result_dir is None:
 
 ######################################################################
 
-if args.dirty_debug:
-    args.accuracy_to_make_c_quizzes = 0.0
-    args.nb_gpts = 2
-    nb_new_c_quizzes_for_train = 100
-    nb_new_c_quizzes_for_test = 10
-
-######################################################################
-
 default_args = {
     "model": "37M",
     "batch_size": 100,
@@ -521,12 +508,30 @@ log_string(f"nb_parameters {nb_parameters} ({int(nb_parameters/1e6)}M)")
 
 ######################################################################
 
+nb_new_c_quizzes_for_train = args.nb_train_samples // 50
+nb_new_c_quizzes_for_test = args.nb_test_samples // 50
+
+log_string(
+    f"nb_new_c_quizzes_for_train {nb_new_c_quizzes_for_train} nb_new_c_quizzes_for_test {nb_new_c_quizzes_for_test}"
+)
+
+######################################################################
+
+if args.dirty_debug:
+    args.accuracy_to_make_c_quizzes = 0.0
+    args.nb_gpts = 2
+    nb_new_c_quizzes_for_train = 100
+    nb_new_c_quizzes_for_test = 10
+
+######################################################################
+
 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))
@@ -547,10 +552,12 @@ for n_epoch in range(args.nb_epochs):
         f"test_set_composition w_quizzes {quiz_machine.nb_batch_w_quizzes} c_quizzes {quiz_machine.nb_batch_c_quizzes}"
     )
 
+    ##################################################
     # Replace a fraction of the w_quizzes with fresh ones
 
     quiz_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
 
index cb187be..45b2247 100755 (executable)
@@ -360,11 +360,11 @@ class QuizMachine:
                 backward_nb_total = correct[n_backward].size(0)
 
                 self.logger(
-                    f"{log_prefix}_forward_accuracy {n_epoch} model {model.id} nb_correct {forward_nb_correct} / {forward_nb_total}"
+                    f"{log_prefix}_forward_accuracy {n_epoch} model {model.id} nb_correct {forward_nb_correct} / {forward_nb_total} ({forward_nb_correct*100/forward_nb_total} %)"
                 )
 
                 self.logger(
-                    f"{log_prefix}_backward_accuracy {n_epoch} model {model.id} nb_correct {backward_nb_correct} / {backward_nb_total}"
+                    f"{log_prefix}_backward_accuracy {n_epoch} model {model.id} nb_correct {backward_nb_correct} / {backward_nb_total} ({backward_nb_correct*100/backward_nb_total} %)"
                 )
 
             return result, correct