X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=main.py;h=d63398c1246158e4e8b7519366a7a4bd95ccd08d;hb=d283cd3d46a6323fec4c6a0970ac71e553e4a486;hp=d194a8d2a27df44fabf7a0dadbeb05380819d9a2;hpb=3b41e2797fc340fd11cb35015b57c3cae1e8447b;p=culture.git diff --git a/main.py b/main.py index d194a8d..d63398c 100755 --- a/main.py +++ b/main.py @@ -79,9 +79,7 @@ parser.add_argument("--dropout", type=float, default=0.1) parser.add_argument("--deterministic_synthesis", action="store_true", default=False) -parser.add_argument("--reverse_cleanup", action="store_true", default=True) - -parser.add_argument("--validation_forward_only", action="store_true", default=False) +parser.add_argument("--both_directions", action="store_true", default=False) parser.add_argument("--problem", type=str, default="sky") @@ -409,11 +407,10 @@ def create_c_quizzes( c_quizzes, ave_seq_logproba = quizz_machine.generate_quizzes( nb_to_create, model_for_generation=model_for_generation, - reverse_cleanup=args.reverse_cleanup, ) nb_correct = quizz_machine.compute_correctness( - c_quizzes, models, both_directions=not args.validation_forward_only + c_quizzes, models, both_directions=args.both_directions ) if args.dirty_debug: @@ -429,7 +426,7 @@ def create_c_quizzes( nb_validated = valid_c_quizzes(recorded, standard_validity).size(0) log_string( - f"keep c_quizzes kept {nv} nb_accumulated {nb_validated} / {nb_to_create}" + f"keep c_quizzes model {model_for_generation.id} kept {nv} nb_accumulated {nb_validated} / {nb_to_create}" ) # store the new c_quizzes which have been validated @@ -487,20 +484,20 @@ 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} ----------------------------------------") + # 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}" ) - # improve it 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}" ) - # test it run_tests(weakest_model, quizz_machine, deterministic_synthesis=False) log_string( @@ -510,9 +507,13 @@ for n_epoch in range(args.nb_epochs): cta = " ".join([f"{float(m.main_test_accuracy):.04f}" for m in models]) log_string(f"current_test_accuracies {cta}") - # replace a fraction of the w_quizzes with fresh ones + # 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, @@ -521,7 +522,6 @@ for n_epoch in range(args.nb_epochs): nb_for_test=nb_new_c_quizzes_for_test, ) - # We update everyone for model in models: run_tests(model, quizz_machine, deterministic_synthesis=False)