pytorch-dataloader

How to remove some labels of a pytorch dataset

How to remove some labels of a pytorch dataset Question: I have a torchvision.datasets object. I only want to keep some labels and delete the others. For example, if my dataset is CFAR10 like this trainset = torchvision.datasets.CIFAR10(root=’./data’, train=True, download=True) I will have 10 labels. I only want to keep the first three labels and …

Total answers: 1

Pytorch DataLoader for custom dataset

Pytorch DataLoader for custom dataset Question: I am trying to write a custom data loader for a dataset where the directory structures is as follows: All_data | ->Numpy_dat | | | -> dat_0 | -> dat_{0}_{0}.npy | . | . | -> dat_1 | -> dat_{0}_{0}.npy | -> dat_{0}_{1}.npy | . | . |->mask_numpy | …

Total answers: 1

Error with __len__(self) function while creating Custom Dataset Object in Pytorch

Error with __len__(self) function while creating Custom Dataset Object in Pytorch Question: I am following a video course for image classification and therein I have created a custom Dataset Class as follows: from torch.utils.data import Dataset class ChestXRayDataSet(Dataset): def __init__(self, image_dirs, transform): # Initialize the Object def get_image(class_name): # define a function to get images …

Total answers: 1

how to connect three dataloaders together in pytorch – parallel not chained

how to connect three dataloaders together in pytorch – parallel not chained Question: i have three same length dataloaders (A,B,C) that load images (a,b,c), i want to create a new dataloader D that loads a dict of images, some syntax for clarity: usually the dataloader works like this: for a in A: a -> an …

Total answers: 1

Problem loading parallel datasets even after using SubsetRandomSampler

Problem loading parallel datasets even after using SubsetRandomSampler Question: I have two parallel datasets dataset1 and dataset2 and following is my code to load them in parallel using SubsetRandomSampler where I provide train_indices for dataloading. P.S. Even after setting num_workers=0 and seeding np as well as torch, the samples do not get loaded in parallel. …

Total answers: 2

AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute 'next'

AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute 'next' Question: I am trying to load the dataset using Torch Dataset and DataLoader, but I got the following error: AttributeError: ‘_MultiProcessingDataLoaderIter’ object has no attribute ‘next’ the code I use is: class WineDataset(Dataset): def __init__(self): # Initialize data, download, etc. # read with numpy or pandas xy = …

Total answers: 3

Pytorch crashes with error IndexError: Target 32 is out of bounds

Pytorch crashes with error IndexError: Target 32 is out of bounds Question: I am attempting to train a model using CIFAR-100 dataset, on CPU. But, I get an error: Traceback (most recent call last): File "recog.py", line 68, in <module> loss = criterion(outputs, labels) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/loss.py", …

Total answers: 1

Pytorch dataloaders : Bad file descriptor and EOF for workers>0

Pytorch dataloaders : Bad file descriptor and EOF for workers>0 Question: Description of the problem I am encountering a strange behavior during a neural network training with Pytorch dataloaders made from a custom dataset. The dataloaders are set with workers=4, pin_memory=False. Most of the time, the training finished with no problems. Sometimes, the training stopped …

Total answers: 2