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

[FEA] Support DGL NegativeSampler needed for Link Prediction #2753

Open
Tracked by #4349
VibhuJawa opened this issue Sep 28, 2022 · 0 comments · May be fixed by rapidsai/cugraph-gnn#50
Open
Tracked by #4349

[FEA] Support DGL NegativeSampler needed for Link Prediction #2753

VibhuJawa opened this issue Sep 28, 2022 · 0 comments · May be fixed by rapidsai/cugraph-gnn#50
Assignees
Labels
feature request New feature or request

Comments

@VibhuJawa
Copy link
Member

Describe the solution you'd like and any additional context

We should scope and test the negative sampling we do for DGL cugraph objects

https://docs.dgl.ai/en/0.9.x/guide/minibatch-link.html#guide-minibatch-link-classification-sampler

class NegativeSampler(object):
    def __init__(self, g, k):
        # caches the probability distribution
        self.weights = g.in_degrees().float() ** 0.75
        self.k = k

    def __call__(self, g, eids):
        src, _ = g.find_edges(eids)
        src = src.repeat_interleave(self.k)
        dst = self.weights.multinomial(len(src), replacement=True)
        return src, dst


sampler = dgl.dataloading.as_edge_prediction_sampler(
    sampler, negative_sampler=NegativeSampler(g, 5))
dataloader = dgl.dataloading.DataLoader(
    g, train_seeds, sampler,
    batch_size=args.batch_size,
    shuffle=True,
    drop_last=False,
    pin_memory=True,
    num_workers=args.num_workers)

Might be related:
https://docs.dgl.ai/en/0.9.x/_modules/dgl/sampling/negative.html#global_uniform_negative_sampling


For Developers below this line

  • [] Code passes CI
  • [] Code uses Graph Primitives
  • [] Code in C++/CUDA layer
  • [] Code in C layer
  • [] Code in pylibcugraph Python layer
  • [] Code in cugraph Python layer
  • [] Documentation
  • [] Test cases at each layer (for MG tests, a note in the PR description indicating the new/existing MG tests were run and passed)
@VibhuJawa VibhuJawa added this to the 22.12 milestone Sep 28, 2022
@VibhuJawa VibhuJawa self-assigned this Sep 28, 2022
@VibhuJawa VibhuJawa reopened this Oct 10, 2022
@BradReesWork BradReesWork modified the milestones: 22.12, 23.02 Dec 7, 2022
@VibhuJawa VibhuJawa modified the milestones: 23.02, 23.04 Jan 4, 2023
@BradReesWork BradReesWork removed this from the 23.04 milestone Jul 24, 2023
@kingmesal kingmesal assigned alexbarghi-nv and unassigned VibhuJawa May 28, 2024
@alexbarghi-nv alexbarghi-nv changed the title [FEA] Support NegativeSampler needed for Link Prediction [FEA] Support DGL NegativeSampler needed for Link Prediction Aug 30, 2024
@alexbarghi-nv alexbarghi-nv added the feature request New feature or request label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants