corenel / pytorch-adda

A PyTorch implementation for Adversarial Discriminative Domain Adaptation
MIT License
474 stars 139 forks source link

0% accuracy with pytorch >= 0.4.0 #10

Open williford opened 6 years ago

williford commented 6 years ago

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 commented 6 years ago

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 commented 5 years ago

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

zzzpc commented 3 years ago

set acc=0.0 and it will be work

TuGang-Git commented 2 years ago

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