I am doing binary classification with a batch size of 8 and the output of my model is:
out shape is: torch.Size([8, 2])
out is: tensor([[-1.2086, 0.8501],
[-0.8705, -0.2427],
[-1.0448, 0.5410],
[-1.2318, 0.2670],
[-1.0920, 0.0126],
[-0.9867, 0.1056],
[-1.2848, 0.9758],
[-1.2415, -0.2882]], device='cuda:0', grad_fn=<AddmmBackward0>)
and I am getting this error:
train loss: 0.0
Traceback (most recent call last):
File "main_classifier.py", line 253, in <module>
train_loss.backward(retain_graph=True)
AttributeError: 'float' object has no attribute 'backward'
How can I solve this error?