I have a dataloader as follows:
import torch
import torch.utils.data as data
import glob
class My_Dataset(data.Dataset):
def __init__(self, root_path):
self.png_list = [x for x in glob.glob(os.path.join(root_path, '*.png'))]
def __getitem__(self, index):
self.data_path= self.png_list[index]
def __len__(self):
return len(self.png_list)
import torch.utils.data as dataloader
data = My_Dataset("./dataset/")
train_loader = dataloader.DataLoader(data, batch_size=10, shuffle=True)
for i, data in enumerate(trainloader):
images, targets = data
For each time, the data will load 10 images as a batch. However, if my png_list is 35, then the third loader only load the 5 remaining png files. It is normal. However, I want to load 10 images in the third time by getting 5 remaining files and first 5 files in the png_list /or random select 5 files in the list. How should I modify the code? Thanks