I need to store some numpy.ndarray into a dataset, but then when I load it out, it seems that the arrays are automatically converted to tensors, am I doing something wrong or how can I still get out arrays?
Thanks in advance!
x.numpy() turns a tensor
x back into a numpy array, if that helps
thanks, but what I meant is that if the dataset can just store ndarray as it is and not turning it into tensors, cos otherwise from np to tensor then to np is too much waste:/
Dataset class itself does not turn your data into
Do you use any transformations from torchvision (e.g. `ToTensor())?
Have a look at this code. I created a dummy
Dataset, store a numpy array in it:
class MyDataset(Dataset): def __init__(self, a): self.data = a def __getitem__(self, index): return self.data[index] def __len__(self): return len(self.data) a = np.random.randn(100, 10, 10) dataset = MyDataset(a) b = dataset print type(b) >> <type 'numpy.ndarray'>