[solved] KeyError: 'unexpected key "module.encoder.embedding.weight" in state_dict'

A more graceful solution is:

name = k.replace(".module", “”) # removing ‘.moldule’ from key

As for me using the k[7:] wasn’t properly removing the ‘module’.

2 Likes