I don’t really know what you are trying to do here using BCELoss, so I will guess according to the info you have given.
Since you said you want to do binary classification and your target is of size torch.Size([10]), I’m guessing it is filled with ones and zeros and you want your network to predict a number between 0.0 and 1.0 aka a probability.
For this to happen you need to change the following:



 Tornike:

self.fc4=nn.Linear(20,2)


to self.fc4=nn.Linear(20,1)
and



 Tornike:

return x


to return x.view(-1, 1).squeeze(1)
This will give you logits as output, but they can be in a greater range than just 0 - 1.
So if you want the probability (0-1) instead of the logits you need to either add a nn.Sigmoid() layer to the end of your network or use nn.BCEWithLogitsLoss  instead of nn.BCELoss.
Which is just BCELoss with a builtin sigmoid.
Using nn.BCEWithLogitsLoss is the recommended option. You can read about it here 8.