Hi Everyone! I’m trying to use a Data Loader in the Pytorch Name Generator Tutorial. I’ve written a simple version of the Dataset and Dataloader, but I get a slightly different output with the Dataloader.
from torch.utils.data import Dataset, DataLoader
class SampleDataset(Dataset):
def __init__(self):
temp = {'English':['Adam','Bill','Chet']}
categories = list(temp.keys())
self.data = [(list(name), list(name[1:])+['<EOS>'], category) for category in categories for name in temp[category]]
def __getitem__(self,index):
return self.data[index]
def __len__(self):
return len(self.data)
x = SampleDataset()
x_DataLoader = DataLoader(x, batch_size=1)
print(x[0])
for piece in x_DataLoader:
print(piece)
break
([‘A’, ‘d’, ‘a’, ‘m’], [‘d’, ‘a’, ‘m’, ‘’], ‘English’)
[[(‘A’,), (‘d’,), (‘a’,), (‘m’,)], [(‘d’,), (‘a’,), (‘m’,), (’’,)], (‘English’,)]
I get this weird tuple around each of my characters with the DataLoader. I don’t understand why
Am I missing something obvious ? Thanks so much!