Created
January 24, 2018 17:53
-
-
Save santi-pdp/d0e9002afe74db04aa5bbff6d076e8fe to your computer and use it in GitHub Desktop.
Toy example in pytorch for binary classification
BCEWithLogitsLoss()
expects logits as inputs and not probabilities, so you shouldnt do y = self.out_act(a3)
BCEWithLogitsLoss()
expects logits as inputs and not probabilities, so you shouldnt doy = self.out_act(a3)
But he's using BCELoss not BCEWithLogitsLoss
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Santi, thank you for this code snippet! It really helped me start understanding how to implement pytorch for classification.
I wanted to point out an error in your code regarding the train_epoch function:
y_hat = net(x_batch)
Where 'net' should actually be 'model' (since this was the argument passed into train_epoch function).
Anyway, thanks for putting this up!