Hi, the bellow section of code is creating the error in the title.
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!
Note: I credit my code to sentdex, I’m only trying to modify it to use for my dataset.
My repository with full code: https://github.com/itisyeetimetoday/pytorch_reggression
Sorry about the messy/incorrect formating. This is my first post here. Please let me know how to fix any errors or mistakes with the formating and site usage in general.