Run "Use_Case_1.py" in CPU mode
Opened this issue · 3 comments
Hi,
My environment is an ubuntu virtual machine, and I have installed the pytorch cpu version.
I tried to run use_case_1.py, and changed line 105 of models.py.
torch.load(model_weight_path, map_location='cpu')
However, I get the error in the figure below:
Then I changed the key in the dictionary to make the names match, and ran it with the following error:
Then I used the reshape function to convert (37, 200) to (200,37).
The program can output the data, but the output data is different every time I run it.
Looking forward to your reply.
Benoit
How did you changed the key in the dictionary?
try changing the line that says self.load_state_dict(torch.load(model_weight_path)) to self.load_state_dict(torch.load(model_weight_path, map_location=torch.device('cpu'))). Also, it is normal for the embedding values to be slightly different between runs.
How did you changed the key in the dictionary?
Add following code after line 105 of models.py
model['layers.0.graph_conv.lin.weight'] = model['layers.0.graph_conv.weight'].reshape(200, 37)
model['layers.1.graph_conv.lin.weight'] = model['layers.1.graph_conv.weight']
model['pool1.graph_pool.gnn.lin_rel.weight'] = model['pool1.graph_pool.gnn.lin_l.weight']
model['pool1.graph_pool.gnn.lin_rel.bias'] = model['pool1.graph_pool.gnn.lin_l.bias']
model['pool1.graph_pool.gnn.lin_root.weight'] = model['pool1.graph_pool.gnn.lin_r.weight']
del model['layers.0.graph_conv.weight']
del model['layers.1.graph_conv.weight']
del model['pool1.graph_pool.gnn.lin_l.weight']
del model['pool1.graph_pool.gnn.lin_l.bias']
del model['pool1.graph_pool.gnn.lin_r.weight']