-
Notifications
You must be signed in to change notification settings - Fork 78
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
[Model & Dataset] facebook & sp2gcl #201
Merged
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
08b2faa
Create facebook.py
777sssa 7810d58
sp2_gcl
777sssa 85dd253
sp2gcl
777sssa 68bc722
sp2-gcl
777sssa 04e1400
sp2_gcl_1
777sssa 4a477d6
sp2_gcl
777sssa d321bca
sp2_gcl_new
777sssa 7a69f51
sp2_gcl_new
777sssa e50e2e8
Merge branch 'main' into sp2gcl
gyzhou2000 d9b6d60
sp2gcl_new
777sssa d41db9c
Merge branch 'sp2gcl' of https://github.com/777sssa/GammaGL into sp2gcl
777sssa 94ab090
Merge remote-tracking branch 'upstream/main' into sp2gcl
d4fb492
change the code of sp2gcl
ba9a242
update
d731cdd
update
58e55a0
update test file
b8146d6
update
4a14c22
update
26d1f1b
update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from typing import Callable, Optional | ||
import os | ||
import numpy as np | ||
import tensorlayerx as tlx | ||
|
||
from gammagl.data import Graph, InMemoryDataset, download_url | ||
|
||
class FacebookPagePage(InMemoryDataset): | ||
r"""The Facebook Page-Page network dataset introduced in the | ||
`"Multi-scale Attributed Node Embedding" | ||
<https://arxiv.org/abs/1909.13021>`_ paper. | ||
Nodes represent verified pages on Facebook and edges are mutual likes. | ||
It contains 22,470 nodes, 342,004 edges, 128 node features and 4 classes. | ||
|
||
Args: | ||
root (str): Root directory where the dataset should be saved. | ||
transform (callable, optional): A function/transform that takes in an | ||
:obj:`gammagl.data.Graph` object and returns a transformed | ||
version. The data object will be transformed before every access. | ||
(default: :obj:`None`) | ||
pre_transform (callable, optional): A function/transform that takes in | ||
an :obj:`gammagl.data.Graph` object and returns a | ||
transformed version. The data object will be transformed before | ||
being saved to disk. (default: :obj:`None`) | ||
force_reload (bool, optional): Whether to re-process the dataset. | ||
(default: :obj:`False`) | ||
""" | ||
|
||
url = 'https://graphmining.ai/datasets/ptg/facebook.npz' | ||
|
||
def __init__( | ||
self, | ||
root: str, | ||
transform: Optional[Callable] = None, | ||
pre_transform: Optional[Callable] = None, | ||
force_reload: bool = False, | ||
) -> None: | ||
super().__init__(root, transform, pre_transform, force_reload=force_reload) | ||
self.data, self.slices=self.load_data(self.processed_paths[0]) | ||
|
||
@property | ||
def raw_file_names(self) -> str: | ||
return 'facebook.npz' | ||
|
||
@property | ||
def processed_file_names(self) -> str: | ||
return tlx.BACKEND + '_data.pt' | ||
|
||
def download(self) -> None: | ||
download_url(self.url, self.raw_dir) | ||
|
||
def process(self) -> None: | ||
data = np.load(self.raw_paths[0], 'r', allow_pickle=True) | ||
x = tlx.convert_to_tensor(data['features'], dtype=tlx.float32) | ||
y = tlx.convert_to_tensor(data['target'], dtype=tlx.int64) | ||
edge_index = tlx.convert_to_tensor(data['edges'], dtype=tlx.int64) | ||
edge_index = edge_index.T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried if this can work in the other backend like 'mindspore'? |
||
|
||
data = Graph(x=x, edge_index=edge_index, y=y) | ||
|
||
if self.pre_transform is not None: | ||
data = self.pre_transform(data) | ||
|
||
self.save_data(self.collate([data]), self.processed_paths[0]) | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, this argument can be optional, as we have a cached mechanism compared to
PyG
.