easezyc / deep-transfer-learning

A collection of implementations of deep domain adaptation algorithms
MIT License
889 stars 205 forks source link

DAN error report #9

Closed VoiceBeer closed 4 years ago

VoiceBeer commented 4 years ago

Hi, thx for ur code.

There's an error when I run the DAN code.

The log can be seen here: image

The only thing I edited in the code is changing the root_path from /data/zhuyc/OFFICE31/ to ./dataset/Original_images/(except for the print log with "tt" and "ttt"). I checked the size of source data and target data but nothing wrong, both are [32, 3, 224, 224]. Is there any mistake in the code or did I run the wrong way?

Thank you in advance and have a good day :>

easezyc commented 4 years ago

I did not meet this question. I suggest that you should: print(source.size()) source = self.cls_fc(source)

VoiceBeer commented 4 years ago

Sorry about replying u this late, I edited ResNet.py: Line 177 from self.cls_fc = nn.Linear(2048, num_classes) to self.cls_fc = nn.Linear(1000, num_classes) and it works. Thank you very much, but why the previous version of this line is 2048?

easezyc commented 4 years ago

I think you have changed my code. The output of the last conv of Resnet50 should be 2048. And the self.cls_fc = nn.Linear(2048, num_class) is right.

VoiceBeer commented 4 years ago

Actually I didn't change the code, but u are right, it should be 2048, but the source data size is [32, 1000], see the image down below, I add one line print("ResNet.py, line188: ", source.size()) before the source = self.cls_fc(source). The dataset is downloaded from the URL given in the README.md. image

easezyc commented 4 years ago
微信图片_20200413133738

Note line 168 in Resnet.py

VoiceBeer commented 4 years ago

I'm so sorry xD. Due to the network issue on my server, I have to download the pth file and upload it to the server. After checking all the files and codes, I just found that I downloaded the ResNet18 model, what a embarrassing mistake :<, so sorry to bother u, now everything works fine and no need to change any code or file.

BTW, I think the solution in issue #4 should be added into the README.md to help others. Really useful.

Anyway, thx a lot! And good day :>.

VoiceBeer commented 4 years ago

Just found u have already added the solution into the main README.md. :>