+ file_name = os.path.join(args.result_dir, f"culture_c_quiz_{n_epoch:04d}_logp.dat")
+
+ with open(file_name, "w") as logp_file:
+ while (
+ valid_c_quizzes(quizzes_and_nb_correct_records, standard_validity).size(0)
+ < nb_to_create
+ ):
+ # Select a model at random to generate the new quizzes
+
+ model_for_generation = models[torch.randint(len(models), (1,))]
+
+ c_quizzes = quiz_machine.generate_quizzes(
+ nb_to_create,
+ model_for_generation=model_for_generation,
+ temperature=args.generation_temperature,
+ )
+
+ # if args.prediction_correctness:
+
+ # else:
+ # logproba = quiz_machine.new(quiz_machine.size(0), len(models))
+ # for q,l in zip(quizzes.split(args.batch_size), logits.split(args.batch_size)):
+ # for model in models:
+ # l[...] = F.cross_entropy(model(q))
+
+ c_quizzes = c_quizzes[quiz_machine.non_trivial(c_quizzes)]
+
+ if c_quizzes.size(0) > 0:
+ nb_correct, seq_logproba = quiz_machine.compute_correctness(
+ c_quizzes,
+ models,
+ bidirectional_validation=args.bidirectional_validation,
+ deterministic_validation=args.deterministic_validation,
+ )
+
+ for n, l in zip(nb_correct, seq_logproba):
+ s = " ".join([str(x.item()) for x in l])
+ logp_file.write(f"{n} {s}\n")
+
+ if args.dirty_debug:
+ nb_correct = torch.randint(
+ len(models) + 1, nb_correct.size(), device=c_quizzes.device
+ )
+
+ quizzes_and_nb_correct_records.append((c_quizzes, nb_correct))
+
+ nv = F.one_hot(nb_correct, num_classes=len(models) + 1).sum(0)
+ nv = " ".join([str(x.item()) for x in nv])
+
+ nb_validated = valid_c_quizzes(
+ quizzes_and_nb_correct_records, standard_validity
+ ).size(0)