Hi
I am facing this waning I don’t understand the warning what does it mean
C:\Users\NUC-i7 8gen\Anaconda3\lib\site-packages\torch\nn\modules\loss.py:431: UserWarning: Using a target size (torch.Size([32, 6])) that is different to the input size (torch.Size([32, 1, 6])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
return F.mse_loss(input, target, reduction=self.reduction)
C:\Users\NUC-i7 8gen\Anaconda3\lib\site-packages\torch\nn\modules\loss.py:431: UserWarning: Using a target size (torch.Size([29, 6])) that is different to the input size (torch.Size([29, 1, 6])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
return F.mse_loss(input, target, reduction=self.reduction)
and my training code is
for epoch in range(num_epochs):
for inputs,labels in train_loader:
inputs = inputs.float()
labels = labels.float()
# Feed Forward
output = model(inputs)
output = output.unsqueeze(1)
# Loss Calculation
loss_train = criterion(output, labels)
train_loss.append(loss_train)
# Clear the gradient buffer (we don't want to accumulate gradients)
optimizer.zero_grad()
# Backpropagation
loss_train.backward()
# Weight Update: w <-- w - lr * gradient
optimizer.step()
#Accuracy
# Since we are using a sigmoid, we will need to perform some thresholding
output = (output>0.5).float()
# Accuracy: (output == labels).float().sum() / output.shape[0]
accuracy = (output == labels).float().mean()
# Print statistics
print("Epoch {}/{}, Loss: {:.3f}, Accuracy: {:.3f}".format(epoch+1,num_epochs, loss_train, accuracy))
Any one can explain to me the warning’s concept.
Thanks in advance.