Actually Dataset and DataLoader are not so complicated. I would strongly advise you to read

  
      github.com
  
  
    pytorch/vision/blob/master/torchvision/datasets/folder.py#L66-L125 71

if get_image_backend() == 'accimage':
    return accimage_loader(path)
else:
    return pil_loader(path)




class ImageFolder(data.Dataset):
"""A generic data loader where the images are arranged in this way: ::


    root/dog/xxx.png
    root/dog/xxy.png
    root/dog/xxz.png


    root/cat/123.png
    root/cat/nsdf3.png
    root/cat/asd932_.png


Args:
    root (string): Root directory path.
    transform (callable, optional): A function/transform that  takes in an PIL image


  This file has been truncated. show original

  
  
    
    
  
  


and

  
      github.com
  
  
    pytorch/pytorch/blob/master/torch/utils/data/dataloader.py#L81-L112 40

        if pin_memory:
            batch = pin_memory_batch(batch)
    except Exception:
        out_queue.put((idx, ExceptionWrapper(sys.exc_info())))
    else:
        out_queue.put((idx, batch))


numpy_type_map = {
'float64': torch.DoubleTensor,
'float32': torch.FloatTensor,
'float16': torch.HalfTensor,
'int64': torch.LongTensor,
'int32': torch.IntTensor,
'int16': torch.ShortTensor,
'int8': torch.CharTensor,
'uint8': torch.ByteTensor,
}




def default_collate(batch):


  This file has been truncated. show original