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

Fix negative sampling. Avoid invalid samples. Also add regression bias. #8

Merged
merged 2 commits into from Mar 13, 2021

Conversation

SherylHYX
Copy link
Contributor

@SherylHYX SherylHYX commented Mar 13, 2021

The first commit: Fix negative sampling. Avoid sampling positive edges and viewing them as non-edges, and avoid sampling negative edges and viewing them as non-edges. Borrow utility functions from torch_geometric.
The trick to avoiding sampling an edge that exists is to map the existent links and the sampled links to some unique numbers (by multiplying the source node with the total number of nodes, then add the target node, ref: https://github.com/rusty1s/pytorch_geometric/blob/712f581642bccc225189fc3eb364ce0642b915a3/torch_geometric/utils/negative_sampling.py#L95) After sampling and mapping, we use NumPy.isin to pick out the invalid links (assumed to be non-existent, but exists), then resample iteratively until no invalid samples exist.

The second commit: Add a bias term in regression to predict link signs. This is to learn some prior distribution of different types of links: positive, negative and none. The bias term can be helpful in dealing with unbalanced links. In the data sets used in SGCN, most links do not exist, and positive links are much more frequent than negative ones.

… as non-edges, and avoid sampling negative edges and viewing them as non-edges. Borrow utility function from torch_geometric.
@SherylHYX SherylHYX changed the title Fix negative sampling. Avoid invalid samples. Fix negative sampling. Avoid invalid samples. Also add regression bias. Mar 13, 2021
@benedekrozemberczki benedekrozemberczki merged commit 851d8d7 into benedekrozemberczki:master Mar 13, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants