Convert Dataset to DoubleTensor

Is there a way to pre-convert dataset to a specific type when using built-in datasets (i.e. MNIST, CIFAR10)?

I have to convert all of my data to double and was thinking of speeding this process up by applying transformations to dataset directly. I tried using transforms.Lambda in a following manner:

                    transforms.Normalize((0.1307,), (0.3081,)),
                    transforms.Lambda(lambda x: x.double()),

However, it still returns FloatTensor. Therefore, I was wondering if there would be a way of using transforms to convert data to DoubleTensor?

Your code is working on my machine:

dataset = datasets.MNIST(root='/home/ptrblck/python/data/', transform=transform)
> torch.DoubleTensor

Could you check again if you’ve used accidentally the wrong transform?

Thanks! Indeed, something was wrong with my transform - it works now.