tomasonjo / blogs

Jupyter notebooks that support my graph data science blog posts at https://bratanic-tomaz.medium.com/
1.29k stars 334 forks source link

Movie_recommendations model.encoder() error #3

Closed pleonova closed 2 years ago

pleonova commented 2 years ago

I've been following along with your following notebook and came across an error was wondering if you might have any insights as how to resolve it? I am fairly new to PyTorch and PyG, so wasn't sure how to fix the error. Any advice would be greatly appreciated!

I have replaced the data with my own, but my data is very similar to the movie example you used. I have not had any other errors aside from the following cell (and the training loop).

Cell:

# Due to lazy initialization, we need to run one model step so the number
# of parameters can be inferred:
with torch.no_grad():
    model.encoder(train_data.x_dict, train_data.edge_index_dict)

optimizer = torch.optim.Adam(model.parameters(), lr=0.01)

Error:

`ValueError: `MessagePassing.propagate` only supports `torch.LongTensor` of shape `[2, num_messages]` or `torch_sparse.SparseTensor` for argument `edge_index`.`

P.S.-Your notebook has been really awesome and all the notes are very helpful!

tomasonjo commented 2 years ago

It's got something to do with the format of the edge_index. Do you correctly convert your data? I am not an expert in pyG, so I would suggest you join their Slack channel, where the maintainers are really active. They've also helped me a lot when writing this post.

pleonova commented 2 years ago

Thank you Tomaz for your quick response! Appreciate your direction. I was able to figure it out, I had accidentally removed the wrong "reverse" label.