KeyError: (<function SafeDataset.__getitem__ at 0x0000025B61310B70>, (1527,), frozenset())
Baldins opened this issue · 3 comments
I am getting the following error:
"KeyError: (<function SafeDataset.getitem at 0x0000025B61310B70>, (1527,), frozenset())"
Do you have any idea of why is this happening?
Thanks in advance for the help!
Are you using SafeDataLoader
or DataLoader
? You need to use SafeDataLoader
.
DataLoader - but it wasn't giving me error before.
Also, if I use SafeDataLoader and I run next(iter(dataloader)) it returns []. So, it seems like it is empty. But I don't get why it is happening.
This is the code:
batch_size = 32
validation_split = .2
shuffle_dataset = False
random_seed= 42
dataset_size = len(dataset_s)
indices = list(range(dataset_size))
split = 480
if shuffle_dataset :
np.random.seed(random_seed)
np.random.shuffle(indices)
train_indices, val_indices = indices[:-split], indices[-split:12032]
train_sampler = SubsetRandomSampler(train_indices)
valid_sampler = SubsetRandomSampler(val_indices)
train_loader = nc.SafeDataLoader(dataset, batch_size=batch_size,
sampler=train_sampler, num_workers=0)
validation_loader = nc.SafeDataLoader(dataset, batch_size=batch_size,
sampler=valid_sampler, num_workers=0)
In [24]:
next(iter(train_loader))
Out[24]:
[]