problem=problem,
nb_train_samples=args.nb_train_samples,
nb_test_samples=args.nb_test_samples,
problem=problem,
nb_train_samples=args.nb_train_samples,
nb_test_samples=args.nb_test_samples,
batch_size=args.physical_batch_size,
result_dir=args.result_dir,
logger=log_string,
batch_size=args.physical_batch_size,
result_dir=args.result_dir,
logger=log_string,
-for input in quizz_machine.batches(split="train", desc="train-entropy"):
- token_count += F.one_hot(input, num_classes=quizz_machine.vocabulary_size()).sum(
+for input in quiz_machine.batches(split="train", desc="train-entropy"):
+ token_count += F.one_hot(input, num_classes=quiz_machine.vocabulary_size()).sum(
nb_test, nb_in_train = 0, 0
for test_subset in subsets_as_tuples(
nb_test, nb_in_train = 0, 0
for test_subset in subsets_as_tuples(
optimizer = torch.optim.Adam(model.parameters(), lr=args.learning_rate)
model.train()
nb_train_samples, acc_train_loss = 0, 0.0
optimizer = torch.optim.Adam(model.parameters(), lr=args.learning_rate)
model.train()
nb_train_samples, acc_train_loss = 0, 0.0
with torch.autograd.no_grad():
model.eval()
nb_test_samples, acc_test_loss = 0, 0.0
nb_samples_accumulated = 0
with torch.autograd.no_grad():
model.eval()
nb_test_samples, acc_test_loss = 0, 0.0
nb_samples_accumulated = 0
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:
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:
# Select a model at random to generate the new quizzes
model_for_generation = models[torch.randint(len(models), (1,))]
# Select a model at random to generate the new quizzes
model_for_generation = models[torch.randint(len(models), (1,))]
nb_to_create,
model_for_generation=model_for_generation,
temperature=args.generation_temperature,
)
nb_to_create,
model_for_generation=model_for_generation,
temperature=args.generation_temperature,
)
nv = F.one_hot(nb_correct, num_classes=len(models) + 1).sum(0)
nv = " ".join([str(x.item()) for x in nv])
nv = F.one_hot(nb_correct, num_classes=len(models) + 1).sum(0)
nv = " ".join([str(x.item()) for x in nv])
- new_c_quizzes = valid_c_quizzes(recorded, standard_validity)
+ new_c_quizzes = valid_c_quizzes(quizzes_and_nb_correct_records, standard_validity)
+
+ quiz_machine.reverse_random_half_in_place(new_c_quizzes)
- quizz_machine.store_c_quizzes(new_c_quizzes[:nb_for_train], for_train=True)
- quizz_machine.store_c_quizzes(new_c_quizzes[nb_for_train:], for_train=False)
+ quiz_machine.store_c_quizzes(new_c_quizzes[:nb_for_train], for_train=True)
+ quiz_machine.store_c_quizzes(new_c_quizzes[nb_for_train:], for_train=False)
# save a bunch of images to investigate what quizzes with a
# certain nb of correct predictions look like
# save a bunch of images to investigate what quizzes with a
# certain nb of correct predictions look like
for n_epoch in range(args.nb_epochs):
log_string(f"--- epoch {n_epoch} ----------------------------------------")
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))
# Select, improve, and eval the worst model
weakest_model = min(models, key=lambda m: float(m.main_test_accuracy))
# If all the models are good enough, generate new quizzes and
# re-compute the test errors
# If all the models are good enough, generate new quizzes and
# re-compute the test errors
nb_for_train=nb_new_c_quizzes_for_train,
nb_for_test=nb_new_c_quizzes_for_test,
)
for model in models:
nb_for_train=nb_new_c_quizzes_for_train,
nb_for_test=nb_new_c_quizzes_for_test,
)
for model in models: