I have a Dataset Class (DS) with 21006 rows by 75 feature columns and 1 output column. my Dataset class splits the data into X & y. (and converts X & y into torch tensors…)
(DS.X is 21006 x 75) (DS.y is 21006 x 1)… I’ve verified this with print (len(DS.X), len(DS.y)) & print(DS.X.shape, DS.y.shape)
len of DS.X & DS.y 21006 21006
shape of … torch.Size([21006, 75]) torch.Size([21006])
I want to pass it through the function ( X_train, X_test, y_train, y_test = train_test_split(DS.X, DS.y, test_size=.25, shuffle=True))
After the train_test_split, I get:
len of X_train & y_train 15754 15754
shape of … torch.Size([15754, 75]) torch.Size([15754]) (note: 75% of 21006 is 15754)
Now I want to pass X_train & y_train into a dataloader but how??? the dataloader seems to accept a dataset, not a tuple. " dl = DataLoader(ds, batch_size=2, shuffle=True)"
I think I want dl = DataLoader(ds=(X_train, y_train), batch_size=2, shuffle = True) …
training_DS = (X_train, y_train)
dataloader = DataLoader(ds=training_DS, batch_size=2, shuffle = True)
for epoch in range(epochs): #outer loop
for step, (X_train, y_train) in enumerate(dataloader): #inner loop
print (epoch, step, len(X_train), y_train[0])
I get this error message: for step, (X_train, y_train) in enumerate(dataloader):
ValueError: not enough values to unpack (expected 2, got 1)
What am I missing / not understanding?
THANK YOU
john.david.deatherage@gmail.com 417 527 4042