divelab / DIG

A library for graph deep learning research
https://diveintographs.readthedocs.io/
GNU General Public License v3.0
1.85k stars 281 forks source link

RuntimeError: Error(s) in loading state_dict for GnnNets: Missing key(s) in state_dict: "model.gnn_layers.0.lin.weight", "model.gnn_layers.1.lin.weight", "model.gnn_layers.2.lin.weight". #217

Open maxheming opened 1 year ago

maxheming commented 1 year ago

I have this problem, RuntimeError: Error(s) in loading state_dict for GnnNets: Missing key(s) in state_dict: "model.gnn_layers.0.lin.weight", "model.gnn_layers.1.lin.weight", "model.gnn_layers.2.lin.weight".

in this code def update_state_dict(self, state_dict): original_state_dict = self.state_dict() print('dict',state_dict.items()) loaded_state_dict = dict() for k, v in state_dict.items(): if k in original_state_dict.keys(): loaded_state_dict[k] = v self.load_state_dict(loaded_state_dict)