I have a 2-class classification problem that implemented with Pytorch, in this model I used the  nn.BCELoss () loss function, but when training the model I encounter the following error:

outputs torch.Size([3, 2])
labels torch.Size([3])
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:1698: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
warnings.warn(“nn.functional.tanh is deprecated. Use torch.tanh instead.”)
ValueError                                Traceback (most recent call last)
 in ()
43         print(‘outputs’,outputs.shape)
44         print(‘labels’,labels.shape)
—> 45         loss = criterion(outputs, labels)
46
47         #backward pass
2 frames
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py in binary_cross_entropy(input, target, weight, size_average, reduce, reduction)
2753         raise ValueError(
2754             "Using a target size ({}) that is different to the input size ({}) is deprecated. "
 → 2755             “Please ensure they have the same size.”.format(target.size(), input.size())
2756         )
2757
ValueError: Using a target size (torch.Size([3])) that is different to the input size (torch.Size([3, 2])) is deprecated. Please ensure they have the same size.
Can anyone guide me to fix this error?