# 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:

``````transform=transforms.Compose(
[
transforms.ToTensor(),
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)
print(dataset.type())
> 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8389637,"math_prob":0.702413,"size":587,"snap":"2022-27-2022-33","text_gpt3_token_len":133,"char_repetition_ratio":0.1663808,"word_repetition_ratio":0.0,"special_character_ratio":0.23850085,"punctuation_ratio":0.21008404,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98717546,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-09T08:33:41Z\",\"WARC-Record-ID\":\"<urn:uuid:5f5b1a59-1404-46cb-8f3b-f1323558bb45>\",\"Content-Length\":\"17709\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4dbaae55-a778-4f65-ae41-1c1a47264cd7>\",\"WARC-Concurrent-To\":\"<urn:uuid:dd4034e3-5b92-4032-94aa-9e74c45c8232>\",\"WARC-IP-Address\":\"159.203.145.104\",\"WARC-Target-URI\":\"https://discuss.pytorch.org/t/convert-dataset-to-doubletensor/41574\",\"WARC-Payload-Digest\":\"sha1:FEJLA742IN7B52JCZOU4FDDTLO4WFDSQ\",\"WARC-Block-Digest\":\"sha1:FJM6UNO4MNLW5UL26EDGYU7433FXWDQK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882570913.16_warc_CC-MAIN-20220809064307-20220809094307-00692.warc.gz\"}"}