wvangansbeke/Unsupervised-Classification

Assertion error in SCAN process

Closed this issue · 1 comments

Hi
Thanks for your code and algorithm.

When i train scan with my own data using ResNet50 backbone.

I have troubled assertion error when loading pretrained pretext_model in SCAN process. (same with #5)

I knew that each weight name of pretrained pretext_model ("~/pretext/model.pth.tar") is wrong with ResNet50 class. This pretext model is trained with my own data.

ex)
pretrained pretext_model:
"module.backbone.layer4.2.bn3.weight"

ResNet50 class on SCAN:
"backbone.layer4.2.bn3.weight"

So All weights name is in the "unexpected keys" in model.load_state_dict(state, strict=False)

I solved this issue by changing the name of each weights in /utils/common_config.py

for key, value in state.copy().items():
    new_key = key.replace('module.','')
    state[new_key] = state.pop(key)

Thanks

Hi,

The error is quite clear. Your model is multi-gpu while we load a single-gpu model (or vice versa). Simply remove 'module' or make the loading multi-gpu.