sequence = f.readline().strip()
pred_mask = f.readline().strip()
assert len(sequence) == len(pred_mask)
- assert set(pred_mask) == {"0", "1", "2"}, f"{set(pred_mask)}"
+ assert set(pred_mask).issubset({"0", "1", "2"}), f"{set(pred_mask)}"
pairs.append((sequence, pred_mask))
symbols = ["#"] + list(set("".join([x[0] for x in pairs])) - set(["#"]))
- print("SANITY", symbols)
self.char2id = dict([(c, n) for n, c in enumerate(symbols)])
self.id2char = dict([(n, c) for c, n in self.char2id.items()])
- print(self.char2id)
-
self.train_input, self.train_pred_masks = self.tensorize(
pairs[:nb_train_samples]
)
self.test_input, self.test_pred_masks = self.tensorize(pairs[nb_train_samples:])
+ assert self.train_input.size(0) == nb_train_samples
+ assert self.test_input.size(0) == nb_test_samples
+
def batches(self, split="train", nb_to_use=-1, desc=None):
assert split in {"train", "test"}
input = self.train_input if split == "train" else self.test_input
return len(self.char2id)
def tensor2str(self, t):
- print(f"{type(t)=}")
return ["".join([self.id2char[x.item()] for x in s]) for s in t]
def produce_results(