thuml / TransNorm

Code release for "Transferable Normalization: Towards Improving Transferability of Deep Neural Networks" (NeurIPS 2019)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

about testing

fengweie opened this issue · comments

Hi, thanks for your very good work, I am currently using your code, but I am having problems loading the weights while testing:.
‘’‘
Missing key(s) in state_dict: "Conv1.conv.1.running_var", "Conv1.conv.1.running_mean", "Conv1.conv.1.running_mean", "Conv1.conv.1. running_var", "Conv1.conv.4.running_var", "Conv1.conv.4.running_mean", "Conv1.conv.4.running_mean", "Conv1.conv.4.running_var", "Conv1.conv.4.running_var", " Conv2.conv.1.running_var", "Conv2.conv.1.running_mean", "Conv2.conv.1.running_mean", "Conv2.conv.1.running_var", "Conv2.conv.1.running_var", "Conv2.conv.4. running_var", "Conv2.conv.4.running_mean", "Conv2.conv.4.running_mean", "Conv2.conv.4.running_var", "Conv2.conv.4.running_var", "Conv3.conv.1.running_var", " Conv3.conv.1.running_mean", "Conv3.conv.1.running_mean", "Conv3.conv.1.running_var",
’‘’
Can you help me to solve this problem, thank you very much!

Sorry for the late reply. Have you solved this problem yet? It seems like a problem of mismatched keys. Before training, the running_mean and running_var of TransNorm are initialized from the standard pre-trained ResNet model. Therefore, there are a few lines of code between Line 87 to Line 89 in trans_norm.py to make the key of weights matching that of the standard pre-trained ResNet model as:
if 'source' in key or 'target' in key:
key = key[:-7]
print(key)
If you aim at loading the weights of the TransNorm after training, you can directly delete these lines of code, since the keys are already matched.