Based on your question I assume you are using two output neurons for the binary classification task.
If that’s the case, your target basically defines which output neuron represents which class.
E.g. if your target is 0 for the current sample, output[0] will represent the logit (or probability) for this class.
I’m not sure, which loss function you are using, but note that nn.CrossEntropyLoss expects logits (no softmax at the end), while nn.NLLLoss expects log probailities (log_softmax at the end).
Alternatively, you could also use a single output neuron and apply nn.BCE(WithLogits)Loss as the loss function.