I am new to pytorch. I have written a basic classification with CNN using keras.
full keras code here
I am trying to build the same network using pytorch. it doesn’t seem to be working. accuracy is as good as a random guess. complete code here
can someone point out my mistakes in pytorch and help me fix it.
There are some small differences in your code.
While you are normalizing your input data in the PyTorch code, it looks like you just scale your data in the keras solution to [0, 1]. It shouldn’t make a big difference and normalizing could also work better than just scaling.
You are also missing a dropout layer in your PyTorch code and the loss function is different.
Could you try to use nn.BCEWithLogitsLoss and set the number of output neurons to 1?
Thanks for the response,
I did the changes, but it doesn’t seem to be working. even if the network is not efficient, i expect it should give some decent prediction. I can see only 50% accuracy which no better than random guess.
Could there be some problem with my validation part of the code ?