I can’t seem to figure out how to create a databunch that works with the fashion MNIST dataset once it is downloaded from torch.datasets.
When I try to load the data into ImageDataBunch.create() and put it into a learner, it gives the error AttributeError: ‘torch.device’ object has no attribute ‘_apply’.
Does anyone have any experience with creating a databunch from the pytorch download data or from raw tensor values?
Images of my code below. Note that CNNModel is just a simple raw CNN I wrote.
Update, i made the CNNModel argument a call, but now the learner is diverging and the loss is crazy big. I think there is something wrong with the databunch.
Update #2, resolved the situation. I forgot to include the loss function and the metrics. There was nothing wrong with the databunch actually. Great news.
This helped me—I guess it’s a convention with PyTorch, but it’s not really clear in the fast.ai docs that the model needs to be instantiated before being passed in to Learner, especially given the examples in the tutorials.
@abduissa,
You were able to create a DataBunch d from train_dataset and test_dataset (PyTorch’s dataset class).
However, even though functions fit_one_cycle() and class instantiations like Learner() work with the aforementioned DataBunch d, functions like show_batch() don’t. Because it doesn’t have the attribute ‘x’ as mentioned in your error message.
Any easy way to create a DataBunch object from PyTorch’s dataset object, and make sure that all the functions in the fastAI library works?
Note: In 2020, I’m assuming the attribute x has been changed to c in the latest fastAI library updates, but the question still holds.