Skip to content

Commit

Permalink
[Doc] Update doc tutorials (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
QingFei1 authored Jun 7, 2022
1 parent 398f931 commit e585a0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/source/tutorial/custom_gnn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ JKNet collects the output of all layers and concatenate them together to get the
super(JKNet, self).__init__()
shapes = [in_feats] + [hidden_size] * num_layers
self.layers = nn.ModuleList([
GCNLayer(shape[i], shape[i+1])
GCNLayer(shapes[i], shapes[i+1])
for i in range(num_layers)
])
self.fc = nn.Linear(hidden_size * num_layers, out_feats)
Expand All @@ -45,7 +45,7 @@ JKNet collects the output of all layers and concatenate them together to get the
h = graph.x
out = []
for layer in self.layers:
h = layer(x)
h = layer(graph,h)
out.append(h)
out = torch.cat(out, dim=1)
return self.fc(out)
Expand Down Expand Up @@ -102,7 +102,7 @@ Now that you have defined your own GNN, you can use dataset/task in CogDL to imm

.. code-block:: python
data = dataset.data
data = build_dataset_from_name("cora")[0]
# Use the JKNet model as defined above
model = JKNet(data.num_features, data.num_classes, 32, 4)
experiment(model=model, dataset="cora", mw="node_classification_mw", dw="node_classification_dw")
Expand Down
10 changes: 5 additions & 5 deletions docs/source/tutorial/graph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ We also implement commonly used operations in ``Graph``:
from cogdl.datasets import build_dataset_from_name
g = build_dataset_from_name("cora")[0]
g.num_nodes
>> 2707
>> 2708
g.num_edges
>> 10184
>> 10556
# Get a subgraph contaning nodes [0, .., 99]
sub_g = g.subgraph(torch.arange(100))
>> Graph(x=[100, 1433], edge_index=[2, 18], y=[100])
Expand Down Expand Up @@ -134,7 +134,7 @@ and others(node features, labels) are concatenated in node dimension. ``cogdl.da
dataset = build_dataset_from_name("mutag")
>> MUTAGDataset(188)
dataswet[0]
dataset[0]
>> Graph(x=[17, 7], y=[1], edge_index=[2, 38])
loader = DataLoader(dataset, batch_size=8)
for batch in loader:
Expand Down Expand Up @@ -179,15 +179,15 @@ reflect to the original graph. However, in-place operation will affect the origi
graph = build_dataset_from_name("cora")[0]
graph.num_edges
>> 10184
>> 10556
with graph.local_graph():
mask = torch.arange(100)
row, col = graph.edge_index
graph.edge_index = (row[mask], col[mask])
graph.num_edges
>> 100
graph.num_edges
>> 10184
>> 10556
graph.edge_weight
>> tensor([1.,...,1.])
Expand Down

0 comments on commit e585a0d

Please sign in to comment.