I’m not sure, what the current issue is, but your current setup has some minor bugs.
Since you are using two output neurons to represent the logits of both classes, you should use nn.LogSoftmax + nn.NLLLoss or raw logits + nn.CrossentropyLoss for your loss function.
Also you don’t need to convert your target to a one-hot representation. Just leave y as the class indices.