Is it possible to have a variable which determines the name of the dataset loaded by torchvision.dataset?
e.g.
dataset_var=‘ImageNet’
imagenet_data = torchvision.datasets.dataset_var(‘path/to/dataset/’)
That does not work but is there another way to make it work?
You could use the internal __dict__
of the torchvision.datasets
module, which is a bit hacky and most likely not the best approach:
dataset_var = 'MNIST'
dataset = datasets.__dict__[dataset_var](
root='./data'
)
Alternatively, just check dataset_var
for a particular string and load the corresponding dataset after the if-condition.
1 Like
Excellent reply! Thanks!!