Sequential MNIST

Hi @conner

To feed an rnn model with batch_first, would need to feed tensors of size batch * sequence * dimension, even if the dimension is one.

You could do this on the dataloader level (where you don’t have the batch dimension, so the output tensor is sequence * dimension) with a transform like

transform = torchvision.transforms.Compose(
             [torchvision.transforms.ToTensor(),
              torchvision.transforms.Lambda(lambda x: x.view(-1,1))
             ])

Then you can use that in the dataset instantiation and use that in the usual DataLoader.

If you want permuted sequential MNIST, you could take

pixel_permutation = torch.randperm(28*28)
transform = torchvision.transforms.Compose(
             [torchvision.transforms.ToTensor(),
              torchvision.transforms.Lambda(lambda x: x.view(-1,1)[pixel_permutation])
             ])

(It is desired that the permutation is fixed.)

If you are looking at implementing this

you’d instantly have a fan-club if you post a link to your implementation. :wink:

Best regards

Thomas

3 Likes