Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0% accuracy with pytorch >= 0.4.0 #10

Open
williford opened this issue Jul 12, 2018 · 4 comments
Open

0% accuracy with pytorch >= 0.4.0 #10

williford opened this issue Jul 12, 2018 · 4 comments

Comments

@williford
Copy link

Downgrading to (py)torch==0.3.1 (required re-processing data) fixed issue. This issue is mainly to help other people who run into the same problem.

Here are my results with torch 0.3.1 and torchvision 0.2.0:

>>> source only <<<
Avg Loss = 0.309243381023407, Avg Accuracy = 91.182796%
>>> domain adaption <<<
Avg Loss = 0.15142789483070374, Avg Accuracy = 95.913978%
@deepmo24
Copy link

It is caused by the 'dtype' of 'acc' . because acc.dtype = int64. In 'eval_src' and 'eval_tgt' function, the line: acc /= len(data_loader.dataset) will always have the result 0 or 1. So we can add acc = acc.float() before acc /= len(data_loader.dataset) . Then you can get the right results!

@jiebiandeshitou
Copy link

AttributeError: 'int' object has no attribute 'float'
why?

@zzzpc
Copy link

zzzpc commented Aug 25, 2021

set acc=0.0 and it will be work

@TuGang-Git
Copy link

rewrite acc=0 as acc=0. and it will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants