3d_vsg
3d_vsg copied to clipboard
Issue when running the Inference script
Hi, I trained the model successfully however, when I wanted to run !python -m src.scripts.inference
I get this error RuntimeError: Error(s) in loading state_dict for SimpleMPGNN: Missing key(s) in state_dict: "conv1.lin.weight", "conv2.lin.weight". Unexpected key(s) in state_dict: "conv1.root", "conv2.root".
Can you please help me solve this issue? Thanks
I encountered the same error. I would appreciate it if you could provide a solution.
I encountered the same error. I would appreciate it if you could provide a solution.
I'm not sure... I just modified the code like this :
model = SimpleMPGNN(dataset.num_node_features, dataset.num_classes, dataset.num_edge_features,
hyperparams["hidden_layers"])
state_dict = torch.load(model_path, map_location=torch.device(device))
# Rename keys to match the current model definition
state_dict['conv1.lin.weight'] = state_dict.pop('conv1.root')
state_dict['conv2.lin.weight'] = state_dict.pop('conv2.root')
# Transpose the weights if necessary
state_dict['conv1.lin.weight'] = state_dict['conv1.lin.weight'].transpose(0, 1)
state_dict['conv2.lin.weight'] = state_dict['conv2.lin.weight'].transpose(0, 1)
model.load_state_dict(state_dict)
model.eval()