feat: optuna optimization performed
This commit is contained in:
parent
2ab4abdf93
commit
fe207962de
5 changed files with 15 additions and 18 deletions
|
|
@ -17,19 +17,18 @@ class LoremIpsumDataset(Dataset):
|
|||
path = join(curdir, "data")
|
||||
self._root = path
|
||||
# Convert text to bytes (UTF-8 encoded)
|
||||
self.dataset = torch.tensor([ord(c) for c in list(_text)], dtype=torch.long)
|
||||
|
||||
sequence_count = self.dataset.shape[0] // 128 # how many vectors of 128 elements can we make
|
||||
self.dataset = self.dataset[:sequence_count * 128]
|
||||
self.dataset = self.dataset.view(-1, 128)
|
||||
|
||||
print(self.dataset.shape)
|
||||
self.dataset = torch.tensor([ord(c) % 256 for c in list(_text)], dtype=torch.long)
|
||||
self.context_length = 128
|
||||
|
||||
def __len__(self):
|
||||
# Number of possible sequences of length sequence_length
|
||||
return self.dataset.size(0)
|
||||
return self.dataset.size(0) - self.context_length
|
||||
|
||||
def __getitem__(self, idx):
|
||||
x = self.dataset[idx: idx + self.context_length]
|
||||
y = self.dataset[idx + self.context_length]
|
||||
|
||||
if self.transform is not None:
|
||||
return self.transform(self.dataset[idx])
|
||||
return self.dataset[idx]
|
||||
x = self.transform(x)
|
||||
|
||||
return x, y
|
||||
|
|
|
|||
Reference in a new issue