Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
9120b5a7
"docs/git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "aaee8ff1f75941dd2be82a180826a052965ce84c"
Unverified
Commit
9120b5a7
authored
Jan 18, 2023
by
Rhett Ying
Committed by
GitHub
Jan 18, 2023
Browse files
[Doc] specify backend as pytorch for tutorials (#5198)
parent
ebca7860
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
37 additions
and
1 deletion
+37
-1
tutorials/blitz/1_introduction.py
tutorials/blitz/1_introduction.py
+2
-0
tutorials/blitz/2_dglgraph.py
tutorials/blitz/2_dglgraph.py
+2
-0
tutorials/blitz/3_message_passing.py
tutorials/blitz/3_message_passing.py
+2
-0
tutorials/blitz/5_graph_classification.py
tutorials/blitz/5_graph_classification.py
+2
-0
tutorials/blitz/6_load_data.py
tutorials/blitz/6_load_data.py
+1
-1
tutorials/dist/1_node_classification.py
tutorials/dist/1_node_classification.py
+2
-0
tutorials/dist/2_link_prediction.py
tutorials/dist/2_link_prediction.py
+2
-0
tutorials/large/L1_large_node_classification.py
tutorials/large/L1_large_node_classification.py
+2
-0
tutorials/large/L2_large_link_prediction.py
tutorials/large/L2_large_link_prediction.py
+2
-0
tutorials/large/L4_message_passing.py
tutorials/large/L4_message_passing.py
+2
-0
tutorials/models/1_gnn/1_gcn.py
tutorials/models/1_gnn/1_gcn.py
+2
-0
tutorials/models/1_gnn/4_rgcn.py
tutorials/models/1_gnn/4_rgcn.py
+2
-0
tutorials/models/1_gnn/6_line_graph.py
tutorials/models/1_gnn/6_line_graph.py
+2
-0
tutorials/models/1_gnn/9_gat.py
tutorials/models/1_gnn/9_gat.py
+2
-0
tutorials/models/2_small_graph/3_tree-lstm.py
tutorials/models/2_small_graph/3_tree-lstm.py
+2
-0
tutorials/models/3_generative_model/5_dgmg.py
tutorials/models/3_generative_model/5_dgmg.py
+2
-0
tutorials/models/4_old_wines/2_capsule.py
tutorials/models/4_old_wines/2_capsule.py
+2
-0
tutorials/multi/1_graph_classification.py
tutorials/multi/1_graph_classification.py
+2
-0
tutorials/multi/2_node_classification.py
tutorials/multi/2_node_classification.py
+2
-0
No files found.
tutorials/blitz/1_introduction.py
View file @
9120b5a7
...
@@ -21,6 +21,8 @@ networks with PyTorch.
...
@@ -21,6 +21,8 @@ networks with PyTorch.
"""
"""
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
...
...
tutorials/blitz/2_dglgraph.py
View file @
9120b5a7
...
@@ -30,6 +30,8 @@ By the end of this tutorial you will be able to:
...
@@ -30,6 +30,8 @@ By the end of this tutorial you will be able to:
# center node to the leaves.
# center node to the leaves.
#
#
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
...
...
tutorials/blitz/3_message_passing.py
View file @
9120b5a7
...
@@ -18,6 +18,8 @@ GNN for node classification <1_introduction>`.
...
@@ -18,6 +18,8 @@ GNN for node classification <1_introduction>`.
"""
"""
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
...
...
tutorials/blitz/5_graph_classification.py
View file @
9120b5a7
...
@@ -13,6 +13,8 @@ By the end of this tutorial, you will be able to
...
@@ -13,6 +13,8 @@ By the end of this tutorial, you will be able to
(Time estimate: 18 minutes)
(Time estimate: 18 minutes)
"""
"""
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
...
...
tutorials/blitz/6_load_data.py
View file @
9120b5a7
...
@@ -88,7 +88,7 @@ interactions.head()
...
@@ -88,7 +88,7 @@ interactions.head()
#
#
import
os
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
torch
import
torch
import
dgl
import
dgl
...
...
tutorials/dist/1_node_classification.py
View file @
9120b5a7
...
@@ -22,6 +22,8 @@ Here we store the node labels as node data in the DGL Graph.
...
@@ -22,6 +22,8 @@ Here we store the node labels as node data in the DGL Graph.
.. code-block:: python
.. code-block:: python
import os
os.environ['DGLBACKEND'] = 'pytorch'
import dgl
import dgl
import torch as th
import torch as th
from ogb.nodeproppred import DglNodePropPredDataset
from ogb.nodeproppred import DglNodePropPredDataset
...
...
tutorials/dist/2_link_prediction.py
View file @
9120b5a7
...
@@ -19,6 +19,8 @@ into a training graph, validation edges and test edges with :class:`~dgl.data.As
...
@@ -19,6 +19,8 @@ into a training graph, validation edges and test edges with :class:`~dgl.data.As
.. code-block:: python
.. code-block:: python
import os
os.environ['DGLBACKEND'] = 'pytorch'
import dgl
import dgl
import torch as th
import torch as th
from ogb.linkproppred import DglLinkPropPredDataset
from ogb.linkproppred import DglLinkPropPredDataset
...
...
tutorials/large/L1_large_node_classification.py
View file @
9120b5a7
...
@@ -25,6 +25,8 @@ Sampling for GNN Training <L0_neighbor_sampling_overview>`.
...
@@ -25,6 +25,8 @@ Sampling for GNN Training <L0_neighbor_sampling_overview>`.
# OGB already prepared the data as DGL graph.
# OGB already prepared the data as DGL graph.
#
#
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
dgl
import
dgl
import
torch
import
torch
import
numpy
as
np
import
numpy
as
np
...
...
tutorials/large/L2_large_link_prediction.py
View file @
9120b5a7
...
@@ -52,6 +52,8 @@ Sampling for Node Classification <L1_large_node_classification>`.
...
@@ -52,6 +52,8 @@ Sampling for Node Classification <L1_large_node_classification>`.
# :doc:`previous tutorial <L1_large_node_classification>`.
# :doc:`previous tutorial <L1_large_node_classification>`.
#
#
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
dgl
import
dgl
import
torch
import
torch
import
numpy
as
np
import
numpy
as
np
...
...
tutorials/large/L4_message_passing.py
View file @
9120b5a7
...
@@ -13,6 +13,8 @@ for stochastic GNN training. It assumes that
...
@@ -13,6 +13,8 @@ for stochastic GNN training. It assumes that
"""
"""
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
dgl
import
dgl
import
torch
import
torch
import
numpy
as
np
import
numpy
as
np
...
...
tutorials/models/1_gnn/1_gcn.py
View file @
9120b5a7
...
@@ -45,6 +45,8 @@ message passing APIs.
...
@@ -45,6 +45,8 @@ message passing APIs.
# aggregation on a node :math:`u` only involves summing over the neighbors'
# aggregation on a node :math:`u` only involves summing over the neighbors'
# representations :math:`h_v`, we can simply use builtin functions:
# representations :math:`h_v`, we can simply use builtin functions:
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
torch
as
th
import
torch
as
th
import
torch.nn
as
nn
import
torch.nn
as
nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
...
...
tutorials/models/1_gnn/4_rgcn.py
View file @
9120b5a7
...
@@ -136,6 +136,8 @@ multiple edges among any given pair.
...
@@ -136,6 +136,8 @@ multiple edges among any given pair.
# efficient :class:`builtin R-GCN layer module <dgl.nn.pytorch.conv.RelGraphConv>`.
# efficient :class:`builtin R-GCN layer module <dgl.nn.pytorch.conv.RelGraphConv>`.
#
#
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
dgl
import
dgl
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
...
...
tutorials/models/1_gnn/6_line_graph.py
View file @
9120b5a7
...
@@ -86,6 +86,8 @@ Line Graph Neural Network
...
@@ -86,6 +86,8 @@ Line Graph Neural Network
# The following code snippet verifies that there are more intra-class edges
# The following code snippet verifies that there are more intra-class edges
# than inter-class.
# than inter-class.
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
torch
import
torch
import
torch
as
th
import
torch
as
th
import
torch.nn
as
nn
import
torch.nn
as
nn
...
...
tutorials/models/1_gnn/9_gat.py
View file @
9120b5a7
...
@@ -104,6 +104,8 @@ structure-free normalization, in the style of attention.
...
@@ -104,6 +104,8 @@ structure-free normalization, in the style of attention.
# DGL provides an off-the-shelf implementation of the GAT layer under the ``dgl.nn.<backend>``
# DGL provides an off-the-shelf implementation of the GAT layer under the ``dgl.nn.<backend>``
# subpackage. Simply import the ``GATConv`` as the follows.
# subpackage. Simply import the ``GATConv`` as the follows.
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
from
dgl.nn.pytorch
import
GATConv
from
dgl.nn.pytorch
import
GATConv
###############################################################
###############################################################
...
...
tutorials/models/2_small_graph/3_tree-lstm.py
View file @
9120b5a7
...
@@ -58,6 +58,8 @@ Tree-LSTM in DGL
...
@@ -58,6 +58,8 @@ Tree-LSTM in DGL
from
collections
import
namedtuple
from
collections
import
namedtuple
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
dgl
import
dgl
from
dgl.data.tree
import
SSTDataset
from
dgl.data.tree
import
SSTDataset
...
...
tutorials/models/3_generative_model/5_dgmg.py
View file @
9120b5a7
...
@@ -50,6 +50,8 @@ Generative Models of Graphs
...
@@ -50,6 +50,8 @@ Generative Models of Graphs
# you can write the code as follows.
# you can write the code as follows.
#
#
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
dgl
import
dgl
g
=
dgl
.
DGLGraph
()
g
=
dgl
.
DGLGraph
()
...
...
tutorials/models/4_old_wines/2_capsule.py
View file @
9120b5a7
...
@@ -67,6 +67,8 @@ offers a different perspective. The tutorial describes how to implement a Capsul
...
@@ -67,6 +67,8 @@ offers a different perspective. The tutorial describes how to implement a Capsul
#
#
# Here's how we set up the graph and initialize node and edge features.
# Here's how we set up the graph and initialize node and edge features.
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
import
torch
as
th
import
torch
as
th
...
...
tutorials/multi/1_graph_classification.py
View file @
9120b5a7
...
@@ -70,6 +70,8 @@ to start the distributed backend at the beginning of each process. We use
...
@@ -70,6 +70,8 @@ to start the distributed backend at the beginning of each process. We use
process ID, which should be an integer from `0` to `world_size - 1`.
process ID, which should be an integer from `0` to `world_size - 1`.
"""
"""
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
torch.distributed
as
dist
import
torch.distributed
as
dist
...
...
tutorials/multi/2_node_classification.py
View file @
9120b5a7
...
@@ -33,6 +33,8 @@ models with multi-GPU with ``DistributedDataParallel``.
...
@@ -33,6 +33,8 @@ models with multi-GPU with ``DistributedDataParallel``.
# tutorial.
# tutorial.
#
#
import
os
os
.
environ
[
'DGLBACKEND'
]
=
'pytorch'
import
dgl
import
dgl
import
torch
import
torch
import
numpy
as
np
import
numpy
as
np
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment