KeyError in SimCLR linear classification
JiarunLiu opened this issue · comments
Hi, Thanks for your amazing work.
I got the following error when i trying to run the linear classification experiment of SimCLR:
Command:
python DDP_linear.py configs/linear/cifar10_res18.py --load ./checkpoints/small/cifar10/simclr_alpha0.1_th0.1/last.pth
Error:
File "/home/futong/jiarunliu/ContrastiveCrop/DDP_linear.py", line 276, in main_worker
load_weights(cfg.load, model, optimizer, resume=False)
File "/home/futong/jiarunliu/ContrastiveCrop/DDP_linear.py", line 107, in load_weights
for k, v in state_dict.items():
UnboundLocalError: local variable 'state_dict' referenced before assignment
And I have checked the aviaible keys in SimCLR's checkpoint:
>>> ckpt = torch.load("checkpoints/small/cifar10/simclr_alpha0.1_th0.1/last.pth", map_location='cpu')
>>> ckpt.keys()
dict_keys(['optimizer_state', 'simclr_state', 'boxes', 'epoch'])
Maybe you should consider change the key here?
Lines 84 to 85 in dab4100
Hi jiarun,
Yes you are right. Thank you for pointing it out. I have fixed the bug.