prakashjayy / pytorch_classifiers

Almost any Image classification problem using pytorch
https://medium.com/@14prakash/almost-any-image-classification-problem-using-pytorch-i-am-in-love-with-pytorch-26c7aa979ec4
GNU General Public License v3.0
132 stars 41 forks source link

Accu is "0" #5

Open Akhiladdh opened 5 years ago

Akhiladdh commented 5 years ago

Even after training for many epoch accuracy is remaining 0.

Epoch 50/199

100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3378/3378 [20:02<00:00, 2.81it/s] train Loss: 0.0236 Acc: 0.0000 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 230/230 [00:40<00:00, 5.74it/s] val Loss: 0.0234 Acc: 0.0000

jeshjesh commented 5 years ago

Initialize the running_corrects to 0.0 instead of 0 in the function train_model in file tars/tars_training.py

Kyfafyd commented 4 years ago

Initialize the running_corrects to 0.0 instead of 0 in the function train_model in file tars/tars_training.py

I have tried your method, but it didn't work, either

Kyfafyd commented 4 years ago

Initialize the running_corrects to 0.0 instead of 0 in the function train_model in file tars/tars_training.py

I have tried your method, but it didn't work, either

I have found the solution

running_corrects += torch.sum(preds == labels.data)

change to

running_corrects += float(torch.sum(preds == labels.data))

as well