Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error of _prepare_subgraphs for negative data #14

Open
lihuiliullh opened this issue Nov 23, 2022 · 3 comments
Open

runtime error of _prepare_subgraphs for negative data #14

lihuiliullh opened this issue Nov 23, 2022 · 3 comments

Comments

@lihuiliullh
Copy link

Do you meet the following problem when you run the code?

subgraphs_neg.append(self._prepare_subgraphs(nodes_neg, r_label_neg, n_labels_neg))

Exception has occurred: AssertionError
For return_array=False, there should be one and only one edge between u and v, but get 0 edges. Please use return_array=True instead

@liangxinyu0514
Copy link

Do you meet the following problem when you run the code?

subgraphs_neg.append(self._prepare_subgraphs(nodes_neg, r_label_neg, n_labels_neg))

Exception has occurred: AssertionError For return_array=False, there should be one and only one edge between u and v, but get 0 edges. Please use return_array=True instead
Classmate, I am also reproducing this model, can you communicate?

@TamSiuhin
Copy link

Encounter the same error. Did you guys solve it? thank you!

@shoron-dutta
Copy link

shoron-dutta commented Oct 21, 2024

My python version is 3.8.10. I installed the author's requirements in a virtual environment and got similar errors.

The assertion error is due to not finding any edge between node 0 and node 1 to begin with. I found that returning an empty array would help instead of throwing this error. I changed the code in subgraph_extraction/datasets.py line 147 from

edges_btw_roots = subgraph.edge_id(0, 1)
to
edges_btw_roots = subgraph.edge_id(0, 1, return_array=True)

Doing this step eliminated the assertion error but the code threw another dimension mismatch error for me in managers/trainer.py file line 58 where they compute the loss:

I fixed it by making this modification:

loss = self.criterion(score_pos.squeeze(), score_neg.view(len(score_pos), -1).mean(dim=1), torch.ones(score_pos.numel()).to(device=self.params.device))

Hope it helps you all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants