pass
# save a file to vizualize quizzes, you can save a txt or png file
- def save_quizzes(self, input, result_dir, filename_prefix, logger):
+ def save_quizzes(self, input, result_dir, filename_prefix):
pass
# returns a pair (forward_tokens, backward_token)
if result_dir is not None:
self.problem.save_quizzes(
- self.train_w_quizzes[:72], result_dir, f"culture_w_quizzes", logger
+ self.train_w_quizzes[:72], result_dir, f"culture_w_quizzes"
)
def batches(self, split="train", desc=None):
)
self.problem.save_quizzes(
- result[:72],
- result_dir,
- f"culture_prediction_{n_epoch:04d}_{model.id:02d}",
- logger,
+ result[:72], result_dir, f"culture_prediction_{n_epoch:04d}_{model.id:02d}"
)
return main_test_accuracy
result.append("".join([self.token2char[v] for v in s]))
return result
- def save_image(self, input, result_dir, filename, logger):
+ def save_image(self, input, result_dir, filename):
img = self.seq2img(input.to("cpu"))
image_name = os.path.join(result_dir, filename)
torchvision.utils.save_image(img.float() / 255.0, image_name, nrow=6, padding=4)
- logger(f"wrote {image_name}")
- def save_quizzes(self, input, result_dir, filename_prefix, logger):
- self.save_image(input, result_dir, filename_prefix + ".png", logger)
+ def save_quizzes(self, input, result_dir, filename_prefix):
+ self.save_image(input, result_dir, filename_prefix + ".png")
######################################################################