):
assert input.size() == ar_mask.size()
- batches = zip(input.split(batch_size), ar_mask.split(batch_size))
+ batches = zip(
+ input.split(batch_size),
+ ar_mask.split(batch_size),
+ seq_logproba.split(batch_size),
+ )
if progress_bar_desc is not None:
batches = tqdm.tqdm(
t = model.training
model.eval()
- for input, ar_mask in batches:
+ for input, ar_mask, seq_logproba in batches:
model.masked_inplace_autoregression(
input=input,
ar_mask=ar_mask,
import world
-class World(Task):
+class QuizzMachine(Task):
def save_image(self, input, result_dir, filename, logger):
img = world.seq2img(input.to("cpu"), self.height, self.width)
image_name = os.path.join(result_dir, filename)
input = input[:nmax]
ar_mask = self.make_ar_mask(input)
result = input.clone() * (1 - ar_mask)
+ seq_logproba = torch.empty(input.size(0), device=self.device)
masked_inplace_autoregression(
model=model,
batch_size=self.batch_size,
input=result,
ar_mask=ar_mask,
- seq_logproba=None,
+ seq_logproba=seq_logproba,
temperature=1.0,
deterministic_synthesis=deterministic_synthesis,
progress_bar_desc=None,
input = self.test_w_quizzes[:96]
ar_mask = self.make_ar_mask(input)
result = input.clone() * (1 - ar_mask)
+ seq_logproba = torch.empty(input.size(0), device=self.device)
masked_inplace_autoregression(
model=model,
batch_size=self.batch_size,
input=result,
ar_mask=ar_mask,
- seq_logproba=None,
+ seq_logproba=seq_logproba,
temperature=1.0,
deterministic_synthesis=deterministic_synthesis,
progress_bar_desc=None,
nb,
model,
other_models,
- min_ave_seq_logproba=None,
+ min_ave_seq_logproba,
):
###############################################################
# Generate quizzes with model
)
ar_mask = torch.full(c_quizzes.size(), 1, device=self.device)
- seq_logproba = torch.empty(nb, device=self.device)
+ seq_logproba = torch.empty(ar_mask.size(0), device=self.device)
temperature = 1
d_temperature = 1
# Oh man that's ugly
if ave_seq_logproba < min_ave_seq_logproba * 1.1:
if d_temperature > 0:
- d_temperature *= -0.5
+ d_temperature *= -1 / 3
temperature += d_temperature
elif ave_seq_logproba > min_ave_seq_logproba:
if d_temperature < 0:
- d_temperature *= -0.5
+ d_temperature *= -1 / 3
temperature += d_temperature
else:
break
)
ar_mask = self.make_ar_mask(c_quizzes)
+ seq_logproba = torch.empty(ar_mask.size(0), device=self.device)
###############################################################
# Check how many of the other models can solve them in both
batch_size=self.batch_size,
input=result,
ar_mask=ar_mask,
- seq_logproba=None,
+ seq_logproba=seq_logproba,
temperature=1.0,
deterministic_synthesis=True,
progress_bar_desc="solving c_quizzes",
batch_size=self.batch_size,
input=reverse_result,
ar_mask=ar_mask,
- seq_logproba=None,
+ seq_logproba=seq_logproba,
temperature=1.0,
deterministic_synthesis=True,
progress_bar_desc="solving reversed c_quizzes",