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

[Example] Temporal Graph Neural Network #2636

Merged
merged 44 commits into from
Mar 23, 2021
Merged

Conversation

Ericcsr
Copy link
Contributor

@Ericcsr Ericcsr commented Feb 5, 2021

Description

Checklist

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [$CATEGORY] (such as [NN], [Model], [Doc], [Feature]])
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented
  • To the my best knowledge, examples are either not affected by this change,
    or have been fixed to be compatible with this change
  • Related issue is referred in this PR
  • If the PR is for a new model/paper, I've updated the example index here.

Changes

examples/pytorch/hardgat/README.md Outdated Show resolved Hide resolved
examples/pytorch/hardgat/hgao.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/data.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/data.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/data.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/modules.py Show resolved Hide resolved
examples/pytorch/tgn/modules.py Show resolved Hide resolved
examples/pytorch/tgn/modules.py Outdated Show resolved Hide resolved
logging.txt Outdated Show resolved Hide resolved
examples/pytorch/tgn/train_gru.py Outdated Show resolved Hide resolved
new_df.i += 1
new_df.idx += 1

return new_df
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the code is adapted from original code, please add a commet: https://github.com/dmlc/dgl/blob/master/examples/pytorch/pointcloud/pointnet/pointnet2.py#L10

train_div = int(0.7*num_edges)
valid_div = int(0.85*num_edges)

self.nn_test_g = dgl.edge_subgraph(self.g,range(valid_div,num_edges))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nn -> new_node

edge_ids = range(self.batch_cnt*self.batch_size,min((self.batch_cnt+1)*self.batch_size,graph.num_edges()))
subgraph = dgl.edge_subgraph(graph,edge_ids)
working_d = DictNode(parent=p_dict,NIDdict=subgraph.ndata[dgl.NID])
subgraph.ndata[dgl.NID] = torch.from_numpy(working_d.GetRootID(range(subgraph.num_nodes())))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use dgl.NID. Currently the behavior of dgl.NID is not clearly defined and this is a dgl system setting. After we get clear the behavior of dgl.NID in system level, we may revisit here.

map_index = self.NIDdict[index]
return self.parent.GetRootID(map_index)

class TemporalDataLoader:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to inherit from pytorch dataloader.


# Fake link embedding and compute score
new_neg,neg_subg = self.node_sampler(neg,ts,mode)
n_ts = ts.repeat(neg_subg.num_nodes())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the correct timestamp.

pred_pos = self.linkpredictor(embedding[pos_src_id],embedding[pos_dst_id])
pred_neg = self.linkpredictor(embedding[pos_src_id],embedding[neg_id])
subg = dgl.remove_self_loop(subg)
subg = dgl.add_self_loop(subg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why self_loop?

examples/pytorch/tgn/data_preprocess.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/logging.txt Outdated Show resolved Hide resolved
examples/pytorch/tgn/train.py Outdated Show resolved Hide resolved
logging.txt Outdated Show resolved Hide resolved
Chen and others added 10 commits March 21, 2021 01:39
examples/pytorch/tgn/data_preprocess.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/dataloading.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/dataloading.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/README.md Outdated Show resolved Hide resolved
examples/pytorch/tgn/data_preprocess.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/dataloading.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/dataloading.py Outdated Show resolved Hide resolved
examples/pytorch/tgn/logging.txt Outdated Show resolved Hide resolved
examples/pytorch/tgn/tgn.py Outdated Show resolved Hide resolved
logging.txt Outdated Show resolved Hide resolved
@sneakerkg sneakerkg merged commit d04d59e into dmlc:master Mar 23, 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.

3 participants