<jupyter_start><jupyter_text>Squares<jupyter_code>class SquareDataset(Dataset):
    def __init__(self, size):
        self.size = size
        self.X = torch.randint(255, (size, 9), dtype=torch.float)

        real_w = torch.tensor([[1,1,1,0,0,0,0,0,0],
                               [0,0,0,1,1,1,0,0,0],
                               [0,0,0,0,0,0,1,1,1]], 
                               dtype=torch.float)

        y = torch.argmax(self.X.mm(real_w.t()), 1)
        
        self.Y = torch.zeros(size, 3, dtype=torch.float) \
                      .scatter_(1, y.view(-1, 1), 1)

    def __getitem__(self, index):
        return (self.X[index], self.Y[index])

    def __len__(self):
        return self.size
squares = SquareDataset(256)
print(squares[34])
print(squares[254])
print(squares[25])
dataloader = DataLoader(squares, batch_size=5)

for batch, (X, Y) in enumerate(dataloader):
    print(X, '\n\n', Y)
    break<jupyter_output><empty_output><jupyter_text>Digits<jupyter_code>digits = datasets.MNIST('data', train=True, download=True,
                    transform=transforms.Compose([
                        transforms.ToTensor(),
                        transforms.Lambda(lambda x: x.view(28*28))
                    ]),
                    target_transform=transforms.Compose([
                        transforms.Lambda(lambda y: torch.zeros(10, dtype=torch.float).scatter_(0, y, 1))
                    ])
                 )

dataloader = DataLoader(digits, batch_size=10, shuffle=True)

for batch, (X, Y) in enumerate(dataloader):
    print(X, '\n\n', Y)
    break<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14693118412895226, 'fraction_numerical': 0.03595784252944823, 'mean_word_length': 2.1218568665377178, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '508346', 'license': 'MIT', 'n_tokens_mistral': 593, 'n_tokens_neox': 558, 'n_words': 85, 'path': 'data.ipynb', 'repo_name': 'awesome-archive/DeepLearningWithPyTorch', 'size': '1613'}