в приведенном ниже разделе кода создается ошибка.
for epoch in range(3): # 3 full passes over the data
for data in trainset: # `data` is a batch of data
X, y = data # X is the batch of features, y is the batch of targets.
net.zero_grad() # sets gradients to 0 before loss calc. You will do this likely every step.
output = net(X.view(-1,11)) # pass in the reshaped batch (recall they are 28x28 atm)
loss = F.nll_loss(output, y) # calc and grab the loss value
loss.backward() # apply this loss backwards thru the network's parameters
optimizer.step() # attempt to optimize weights to account for loss/gradients
print(loss) # print loss. We hope loss (a measure of wrong-ness) declines!
В частности, эта строка создает ошибку: X, y = data # X - набор функций, y - набор целей.
, и он генерирует эту ошибку:
ValueError Traceback (most recent call last)
<ipython-input-4-3e67ca89b0ac> in <module>
1 for epoch in range(3): # 3 full passes over the data
2 for data in trainset: # `data` is a batch of data
----> 3 X, y = data # X is the batch of features, y is the batch of targets.
4 net.zero_grad() # sets gradients to 0 before loss calc. You will do this likely every step.
5 output = net(X.view(-1,11)) # pass in the reshaped batch (recall they are 28x28 atm)
ValueError: too many values to unpack (expected 2)
Я уверен, как исправить ошибку.
Примечание: я зачисляю свой код на sentdex, я только пытаюсь изменить его для использования в моем наборе данных. Мой репозиторий с полным кодом: https://github.com/itisyeetimetoday/pytorch_reggression 1