Binary classification Different input sizes error

I have looked at the other post you linked.
Having read what you posted there, I think you were already on the right track.

I am not sure that what I am going to say now is “the final answer”, but concerning the shape issue, it would work if you combine your previous classifier

with your current one

So it would be something like:

self.classifier = nn.Sequential(nn.Linear(n_hidden, n_classes),
                                nn.Sigmoid())

With one more change!!!
Change the n_classes from 2 to 1. This might sound weird because you have two classes 0 and 1.
But as I explained in Tornikes Problem above, if you have a binary classification with labels being 0 and 1, you normally want your output to be a probability in range 0-1.

If this works you can further optimize it by taking out the nn.Sigmoid() and switch to nn.BCEWithLogitsLoss() as a loss function, as recommended by pytorch.
You can read about it above.