Chadrick Blog

torchvision fakedata example

torchvision supports various datasets and one of them is fakedata dataset. I was curious what this actually generated and here is an example

import torchvision, torch

torch.seed()

d = torchvision.datasets.FakeData(10, (3, 50,50), 4)

print(len(d))
print(d\[0\])

a = d\[0\]\[0\]
c = d\[0\]\[1\]

print(c)
a.save('test.png')

"""
output:
10
(<PIL.Image.Image image mode=RGB size=50x50 at 0x7F06F462F050>, tensor(2))
tensor(2)
"""

the result is just an random RGB noised image.