Getting the following error. Not sure what’s happening given I only give in two inputs?
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-70-faa5cb9b2378> in <module>()
----> 1 for batch, target in train_loader:
2 print(batch)
3 frames
<ipython-input-62-a9f98bef985f> in pad_collate(batch)
1 def pad_collate(batch):
----> 2 (xx, yy) = zip(*batch)
3 x_len = [len(x) for x in xx] # length of each tweet
4
5 xx_pad = pad_sequence(xx, batch_first=True, padding_value=0)
ValueError: too many values to unpack (expected 2)
X = [torch.tensor(tweet) for tweet in X]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
def pad_collate(batch):
(xx, yy) = zip(*batch)
x_len = [len(x) for x in xx] # length of each tweet
xx_pad = pad_sequence(xx, batch_first=True, padding_value=0)
return xx_pad, yy, x_len
batch_size = 200
train = (X_train, y_train)
test = (X_test, y_test)
train_loader = DataLoader(train, batch_size=batch_size, shuffle=True, collate_fn=pad_collate)
test_loader = DataLoader(test, batch_size=batch_size, shuffle=True, collate_fn=pad_collate)
for batch, target in train_loader:
print(batch)