Skip to content

Commit 7e0d141

Browse files
cleanup
1 parent 401147e commit 7e0d141

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

docs/src/gnngraph.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ We have also seen some useful methods such as [`adjacency_matrix`](@ref) and [`e
4242
## Data Features
4343

4444
```julia
45-
GNNGraph(sprand(10, 0.3), ndata = (; X=rand(32, 10)))
45+
GNNGraph(erods_renyi(10, 30), ndata = (; X=rand(Float32, 32, 10)))
4646
# or equivalently
47-
GNNGraph(sprand(10, 0.3), ndata=rand(32, 10))
47+
GNNGraph(sprand(10, 0.3), ndata=rand(Float32, 32, 10))
4848

49+
g = GNNGraph(sprand(10, 0.3), ndata = (X=rand(Float32, 32, 10), y=rand(Float32, 10)))
4950

50-
g = GNNGraph(sprand(10, 0.3), ndata = (X=rand(32, 10), y=rand(10)))
51-
52-
g = GNNGraph(g, edata=rand(6, g.num_edges))
51+
g = GNNGraph(g, edata=rand(Float32, 6, g.num_edges))
5352
```
5453

5554

@@ -64,16 +63,36 @@ g = remove_self_loops(g)
6463
## Batches and Subgraphs
6564

6665
```julia
67-
g = Flux.batch([g1, g2, g3])
66+
using Flux
6867

69-
subgraph(g, 2:3)
70-
```
68+
gall = Flux.batch([GNNGraph(erdos_renyi(10, 30), ndata=rand(3,10)) for _ in 1:100])
69+
70+
subgraph(gall, 2:3)
7171

7272

73+
# DataLoader compatibility
74+
train_loader = Flux.Data.DataLoader(gall, batchsize=16, shuffle=true)
75+
76+
for g for gall
77+
@assert g.num_graphs == 16
78+
@assert g.num_nodes == 160
79+
@assert size(g.ndata.X) = (3, 160)
80+
.....
81+
end
82+
```
83+
7384
## LightGraphs integration
7485

7586
```julia
7687
@assert LightGraphs.isdirected(g)
7788
```
7889

90+
## GPU movement
91+
92+
```julia
93+
using Flux: gpu
94+
95+
g |> gpu
96+
```
97+
7998
## Other methods

0 commit comments

Comments
 (0)