Empty/Malformed DataLoader

I am working on a VGG-based GAN building off of an existing project entitled CartoonGAN: https://github.com/znxlwm/pytorch-CartoonGAN. Overall, the model is not training and returning NaN for the loss functions. I am pretty sure this is because there is an issue with the data loading. The author of the original project defined a “data_load” function to wrap around the PyTorch “DataLoader” function. Posted below:

ef data_load(path, subfolder, transform, batch_size, shuffle=False, drop_last=True):
    dset = datasets.ImageFolder(path, transform)
    ind = dset.class_to_idx[subfolder]

    n = 0
    for i in range(dset.__len__()):
        if ind != dset.imgs[n][1]:
            del dset.imgs[n]
            n -= 1

        n += 1

    return torch.utils.data.DataLoader(dset, 
           batch_size=batch_size, shuffle=shuffle, drop_last=drop_last)

I think the DataLoader object that is returned is either empty or malformed. I believe all of the arguments based to the wrapper are correct and the error occurs within the function.

I can’t pinpoint where the failure is and I’m wondering if anyone has some insight.

Thanks!