question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why accuracy is remaining 0?

See original GitHub issue

Hi, I follow your README to run the code, but the classification accuracy is remaining 0 after several epoch. Is there something important I neglected? Thank you very much!

[epoch   4: 160/307] 	 train loss: 0.928064 	 lr: 0.00100
[epoch   4: 180/307] 	 train loss: 0.486494 	 lr: 0.00100
[epoch   4: 200/307] 	 train loss: 0.455191 	 lr: 0.00100
[epoch   4: 220/307] 	 train loss: 0.509143 	 lr: 0.00100
[epoch   4: 240/307] 	 train loss: 0.903722 	 lr: 0.00100
[epoch   4: 260/307] 	 train loss: 0.333634 	 lr: 0.00100
[epoch   4: 280/307] 	 train loss: 0.712478 	 lr: 0.00100

val loss: 0.488999 	 acc: 0.000000

[epoch   4: 300/307] 	 train loss: 0.461941 	 lr: 0.00100
[epoch   5:   0/307] 	 train loss: 0.480295 	 lr: 0.00100
[epoch   5:  20/307] 	 train loss: 0.308337 	 lr: 0.00100
[epoch   5:  40/307] 	 train loss: 0.756740 	 lr: 0.00100
[epoch   5:  60/307] 	 train loss: 0.552190 	 lr: 0.00100
[epoch   5:  80/307] 	 train loss: 0.518123 	 lr: 0.00100
[epoch   5: 100/307] 	 train loss: 0.719212 	 lr: 0.00100
[epoch   5: 120/307] 	 train loss: 0.408349 	 lr: 0.00100
[epoch   5: 140/307] 	 train loss: 0.633257 	 lr: 0.00100

val loss: 0.446945 	 acc: 0.000000

[epoch   5: 160/307] 	 train loss: 0.779942 	 lr: 0.00100
[epoch   5: 180/307] 	 train loss: 0.585827 	 lr: 0.00100
[epoch   5: 200/307] 	 train loss: 0.550597 	 lr: 0.00100
[epoch   5: 220/307] 	 train loss: 0.406125 	 lr: 0.00100
[epoch   5: 240/307] 	 train loss: 0.290858 	 lr: 0.00100
[epoch   5: 260/307] 	 train loss: 0.365490 	 lr: 0.00100
[epoch   5: 280/307] 	 train loss: 0.821365 	 lr: 0.00100

val loss: 0.458882 	 acc: 0.000000

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jofurycommented, Oct 21, 2019

@RandyCHz What version of PyTorch do you use? The val loss looks like all rihgt, you may need to check line 154-159 in train_cls.py, just print them to see what wrong is.

It seems to be a datatype question, I change it to float and it works. Thanks!

Hi, I got the same problem when I ran the code.Where can I change the data type? How did you solve it?

At line 159 in train_cls.py, change (preds ==labels).sum() to (preds ==labels).sum().item() as suggested by @ANGELALIGN-BOWEN

0reactions
LX-meteorcommented, Oct 22, 2019

@jofury It works ! Thank you !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the accuracy for my Keras model always 0 when ...
I updated my answer. However, that doesn't change the fact that as it currently written, the model corresponds to a regression problem.
Read more >
machine learning - Why does accuracy remain the same
A "reasonable" scale is usually something in the range of a 0-mean, unit-variance normal distribution. Effect of fixing these issues. Let's look ...
Read more >
My dogs vs cats models always have 0.5 accuracy
Again, same thing: accuracy 0.5. During training, accuracy always hovers around 0.5, and doesn't improve. Training more epochs doesn't help.
Read more >
Training accuracy remains constant and loss keeps decreasing
There could be multiple reasons for this, including a high learning rate, outlier data being used while training etc. You can try reducing...
Read more >
Train loss is decreasing, but accuracy remain the same
This means you are overfitting (training loss diminished but no improvement in validation loss/accuracy) so you should try using any technique ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found