Oscar_Rangel:

But I though that we need to use 1 for two class classification. and two was for more than 2.


No. You can use a single output with e.g. nn.BCEWithLogitsLoss for a binary classification.
Alternatively you could also use two outputs with nn.CrossEntropyLoss for a “two class classification”, which would also classify each sample to one of two classes.
Note that the latter approach will double the output units and thus the last weight matrix.
Besides using another loss function, the target would also be different.
nn.BCEWithLogitsLoss expects the target as a FloatTensor with values in the range [0, 1], while nn.CrossEntropyLoss expects it to be a LongTensor with class indices in the range [0, num_classes-1].