trainloader = utilsxai.load_data_cifar10(batch_size=1,test=False)
this is my dataset from torchvision
trainloader.dataset.data.shape = (50000, 32, 32, 3)
I want to replace this with
sal_maps_hf.shape = (50000, 3, 224, 224)
So I try to replace it like this
trainloader.dataset.data = sal_maps_hf

but got error message following
for idx,(img,target) in enumerate(trainloader):
   print(img)


----> 1 for idx,(img,target) in enumerate(trainloader):
TypeError: Cannot handle this data type
TypeError                                 Traceback (most recent call
last)  in 
----> 1 for idx,(img,target) in enumerate(trainloader):
2     img = img.squeeze()
3     #pritn(img)
4     img = torch.tensor(img)
5     print(img.shape)
~/venv/lib/python3.7/site-packages/torch/utils/data/dataloader.py in
next(self)
344     def next(self):
345         index = self._next_index()  # may raise StopIteration
–> 346         data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
347         if self._pin_memory:
348             data = _utils.pin_memory.pin_memory(data)
~/venv/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py in
fetch(self, possibly_batched_index)
42     def fetch(self, possibly_batched_index):
43         if self.auto_collation:
—> 44             data = [self.dataset[idx] for idx in possibly_batched_index]
45         else:
46             data = self.dataset[possibly_batched_index]
~/venv/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py in
(.0)
42     def fetch(self, possibly_batched_index):
43         if self.auto_collation:
—> 44             data = [self.dataset[idx] for idx in possibly_batched_index]
45         else:
46             data = self.dataset[possibly_batched_index]
~/venv/lib/python3.7/site-packages/torchvision/datasets/cifar.py in
getitem(self, index)
120         # doing this so that it is consistent with all other datasets
121         # to return a PIL Image
–> 122         img = Image.fromarray(img)
123
124         if self.transform is not None:
~/venv/lib/python3.7/site-packages/PIL/Image.py in fromarray(obj,
mode)    2645             mode, rawmode = _fromarray_typemap[typekey]
2646         except KeyError:
-> 2647             raise TypeError(“Cannot handle this data type”)    2648     else:    2649         rawmode = mode
TypeError: Cannot handle this data type