wvangansbeke/Unsupervised-Classification

AssertionError in the SCAN loss part

Closed this issue · 3 comments

I have run the simclr.py part.
In the scan.py, there is an assertion error.

Unsupervised-Classification/utils/common_config.py", line 89, in get_model
    assert(set(missing[1]) == {
AssertionError

The error happens in this part:

assert(set(missing[1]) == {
                'contrastive_head.0.weight', 'contrastive_head.0.bias', 
                'contrastive_head.2.weight', 'contrastive_head.2.bias'}
                or set(missing[1]) == {
                'contrastive_head.weight', 'contrastive_head.bias'})

I print out the missing[1] and found it contains much more weight, including the backbone weights, and causes the error.
I comment the assert part and the performance wasn't good:

{'ACC': 0.4313, 'ARI': 0.22229977451486435, 'NMI': 0.3281780571616542, 'ACC Top-5': 0.8845, 'hungarian_match': [(0, 0), (1, 2), (2, 1), (3, 8), (4, 6), (5, 3), (6, 9), (7, 4
), (8, 7), (9, 5)]}

Is the weight loading part had some error? Or the simclr.py result was wrong that causes the weight loading error?

Thanks!

Hi @brian7685,

Hmm this is weird. The loading did not happen correctly if it throws you the AssertionError, resulting in low accuracy. I will see if I also get this.

Hi @brian7685,

I had a quick look and didn't notice any problems (I got 81% after 20 epochs with scan.py). I just used the pretrained Simclr model (see download link in README). Maybe give that a try. Also make sure all the paths are correct as stated in the README. If the AssertionError persists, I will download this github repository and start from scratch.

Hope this helps.

Hi @brian7685,

Do you still have this issue? Otherwise I will close it.