pytorch-adda
pytorch-adda copied to clipboard
0% accuracy with pytorch >= 0.4.0
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%
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!
AttributeError: 'int' object has no attribute 'float' why?
set acc=0.0 and it will be work
rewrite acc=0 as acc=0. and it will work