Skip to content

Commit 8c32f74

Browse files
add reference to PyGDatasets (#578)
1 parent 2dd14fd commit 8c32f74

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

GNNGraphs/docs/src/guides/datasets.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,44 @@
11
# Datasets
22

3-
GNNGraphs.jl doesn't come with its own datasets, but leverages those available in the Julia (and non-Julia) ecosystem. In particular, the [examples in the GraphNeuralNetworks.jl repository](https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/tree/master/examples) make use of the [MLDatasets.jl](https://github.com/JuliaML/MLDatasets.jl) package. There you will find common graph datasets such as Cora, PubMed, Citeseer, TUDataset and [many others](https://juliaml.github.io/MLDatasets.jl/dev/datasets/graphs/).
3+
GNNGraphs.jl doesn't come with its own datasets, but leverages those available in the Julia (and non-Julia) ecosystem.
4+
5+
## MLDatasets.jl
6+
7+
Some of the [examples in the GraphNeuralNetworks.jl repository](https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/tree/master/examples) make use of the [MLDatasets.jl](https://github.com/JuliaML/MLDatasets.jl) package. There you will find common graph datasets such as Cora, PubMed, Citeseer, TUDataset and [many others](https://juliaml.github.io/MLDatasets.jl/dev/datasets/graphs/).
48
For graphs with static structures and temporal features, datasets such as METRLA, PEMSBAY, ChickenPox, and WindMillEnergy are available. For graphs featuring both temporal structures and temporal features, the TemporalBrains dataset is suitable.
59

610
GraphNeuralNetworks.jl provides the [`mldataset2gnngraph`](@ref) method for interfacing with MLDatasets.jl.
711

12+
## PyGDatasets.jl
13+
14+
The package [PyGDatasets.jl](https://github.com/CarloLucibello/PyGDatasets.jl) makes available to Julia users the datasets from the [pytorch geometric](https://pytorch-geometric.readthedocs.io/en/latest/modules/datasets.html) library.
15+
16+
PyGDatasets' datasets are compatible with GNNGraphs, so no additional conversion is needed.
17+
```julia
18+
julia> using PyGDatasets
19+
20+
julia> dataset = load_dataset("TUDataset", name="MUTAG")
21+
TUDataset(MUTAG) - InMemoryGNNDataset
22+
num_graphs: 188
23+
node_features: [:x]
24+
edge_features: [:edge_attr]
25+
graph_features: [:y]
26+
root: /Users/carlo/.julia/scratchspaces/44f67abd-f36e-4be4-bfe5-65f468a62b3d/datasets/TUDataset
27+
28+
julia> g = dataset[1]
29+
GNNGraph:
30+
num_nodes: 17
31+
num_edges: 38
32+
ndata:
33+
x = 7×17 Matrix{Float32}
34+
edata:
35+
edge_attr = 4×38 Matrix{Float32}
36+
gdata:
37+
y = 1-element Vector{Int64}
38+
39+
julia> using MLUtils: DataLoader
40+
41+
julia> data_loader = DataLoader(dataset, batch_size=32);
42+
```
43+
44+
PyGDatasets is based on [PythonCall.jl](https://github.com/JuliaPy/PythonCall.jl). It carries over some heavy dependencies such as python, pytorch and pytorch geometric.

GNNGraphs/src/gnnheterograph/generate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ See [`rand_heterograph`](@ref) for a more general version.
9595
9696
# Examples
9797
98-
```julia-repl
98+
```julia
9999
julia> g = rand_bipartite_heterograph((10, 15), 20)
100100
GNNHeteroGraph:
101101
num_nodes: (:A => 10, :B => 15)

GNNlib/Project.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ version = "1.0.0"
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
88
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
99
GNNGraphs = "aed8fd31-079b-4b5a-b342-a13352159b8c"
10-
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1110
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1211
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
1312
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
@@ -22,17 +21,12 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
2221
GNNlibAMDGPUExt = "AMDGPU"
2322
GNNlibCUDAExt = "CUDA"
2423

25-
# GPUArraysCore is not needed as a direct dependency
26-
# but pinning it to 0.1 avoids problems when we do Pkg.add("CUDA") in testing
27-
# See https://github.com/JuliaGPU/CUDA.jl/issues/2564
28-
2924
[compat]
3025
AMDGPU = "1"
3126
CUDA = "5"
3227
ChainRulesCore = "1.24"
3328
DataStructures = "0.18"
3429
GNNGraphs = "1.4"
35-
GPUArraysCore = "0.1"
3630
LinearAlgebra = "1"
3731
MLUtils = "0.4"
3832
NNlib = "0.9"

GNNlib/src/layers/pool.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ topk_index(y::Adjoint, k::Int) = topk_index(y', k)
2929
function set2set_pool(l, g::GNNGraph, x::AbstractMatrix)
3030
n_in = size(x, 1)
3131
qstar = zeros_like(x, (2*n_in, g.num_graphs))
32-
h = zeros_like(l.Wh, size(l.Wh, 2))
33-
c = zeros_like(l.Wh, size(l.Wh, 2))
32+
h = zeros_like(l.lstm.Wh, size(l.lstm.Wh, 2))
33+
c = zeros_like(l.lstm.Wh, size(l.lstm.Wh, 2))
3434
state = (h, c)
3535
for t in 1:l.num_iters
3636
q, state = l.lstm(qstar, state) # [n_in, n_graphs]

GraphNeuralNetworks/src/layers/pool.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ function Set2Set(n_in::Int, n_iters::Int, n_layers::Int = 1)
155155
return Set2Set(lstm, n_iters)
156156
end
157157

158-
function (l::Set2Set)(g, x)
159-
m = (; l.lstm, l.num_iters, Wh = l.lstm.Wh)
160-
return GNNlib.set2set_pool(m, g, x)
161-
end
158+
(l::Set2Set)(g, x) = GNNlib.set2set_pool(l, g, x)
162159

163160
(l::Set2Set)(g::GNNGraph) = GNNGraph(g, gdata = l(g, node_features(g)))

0 commit comments

Comments
 (0)