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
edb97877
Unverified
Commit
edb97877
authored
Nov 30, 2020
by
Mufei Li
Committed by
GitHub
Nov 30, 2020
Browse files
[Doc, UG, Tutorial] Misc Fix (#2376)
* Update * Update * Update * Update * Update
parent
6b02babb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
docs/source/guide/training-edge.rst
docs/source/guide/training-edge.rst
+1
-2
python/dgl/convert.py
python/dgl/convert.py
+2
-0
tutorials/basics/1_first.py
tutorials/basics/1_first.py
+1
-1
tutorials/models/1_gnn/1_gcn.py
tutorials/models/1_gnn/1_gcn.py
+8
-9
No files found.
docs/source/guide/training-edge.rst
View file @
edb97877
...
@@ -3,8 +3,7 @@
...
@@ -3,8 +3,7 @@
5.2
Edge
Classification
/
Regression
5.2
Edge
Classification
/
Regression
---------------------------------------------
---------------------------------------------
Sometimes
you
wish
to
predict
the
attributes
on
the
edges
of
the
graph
,
Sometimes
you
wish
to
predict
the
attributes
on
the
edges
of
the
graph
.
In
that
or
even
whether
an
edge
exists
or
not
between
two
given
nodes
.
In
that
case
,
you
would
like
to
have
an
*
edge
classification
/
regression
*
model
.
case
,
you
would
like
to
have
an
*
edge
classification
/
regression
*
model
.
Here
we
generate
a
random
graph
for
edge
prediction
as
a
demonstration
.
Here
we
generate
a
random
graph
for
edge
prediction
as
a
demonstration
.
...
...
python/dgl/convert.py
View file @
edb97877
...
@@ -259,6 +259,8 @@ def heterograph(data_dict,
...
@@ -259,6 +259,8 @@ def heterograph(data_dict,
formats and chooses the most efficient one depending on the computation invoked.
formats and chooses the most efficient one depending on the computation invoked.
If memory usage becomes an issue in the case of large graphs, use
If memory usage becomes an issue in the case of large graphs, use
:func:`dgl.DGLGraph.formats` to restrict the allowed formats.
:func:`dgl.DGLGraph.formats` to restrict the allowed formats.
4. DGL internally decides a deterministic order for the same set of node types and canonical
edge types, which does not necessarily follow the order in :attr:`data_dict`.
Examples
Examples
--------
--------
...
...
tutorials/basics/1_first.py
View file @
edb97877
...
@@ -64,7 +64,7 @@ def build_karate_club_graph():
...
@@ -64,7 +64,7 @@ def build_karate_club_graph():
u
=
np
.
concatenate
([
src
,
dst
])
u
=
np
.
concatenate
([
src
,
dst
])
v
=
np
.
concatenate
([
dst
,
src
])
v
=
np
.
concatenate
([
dst
,
src
])
# Construct a DGLGraph
# Construct a DGLGraph
return
dgl
.
DGLG
raph
((
u
,
v
))
return
dgl
.
g
raph
((
u
,
v
))
###############################################################################
###############################################################################
# Print out the number of nodes and edges in our newly constructed graph:
# Print out the number of nodes and edges in our newly constructed graph:
...
...
tutorials/models/1_gnn/1_gcn.py
View file @
edb97877
...
@@ -49,7 +49,7 @@ import torch.nn as nn
...
@@ -49,7 +49,7 @@ import torch.nn as nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
from
dgl
import
DGLGraph
from
dgl
import
DGLGraph
gcn_msg
=
fn
.
copy_
src
(
src
=
'h'
,
out
=
'm'
)
gcn_msg
=
fn
.
copy_
u
(
u
=
'h'
,
out
=
'm'
)
gcn_reduce
=
fn
.
sum
(
msg
=
'm'
,
out
=
'h'
)
gcn_reduce
=
fn
.
sum
(
msg
=
'm'
,
out
=
'h'
)
###############################################################################
###############################################################################
...
@@ -95,15 +95,14 @@ print(net)
...
@@ -95,15 +95,14 @@ print(net)
###############################################################################
###############################################################################
# We load the cora dataset using DGL's built-in data module.
# We load the cora dataset using DGL's built-in data module.
from
dgl.data
import
citation_graph
as
citegrh
from
dgl.data
import
CoraGraphDataset
import
networkx
as
nx
def
load_cora_data
():
def
load_cora_data
():
data
=
citegrh
.
load_cora
()
data
set
=
CoraGraphDataset
()
features
=
th
.
FloatTensor
(
data
.
features
)
g
=
dataset
[
0
]
labels
=
th
.
LongTensor
(
data
.
labels
)
features
=
g
.
ndata
[
'feat'
]
train_mask
=
th
.
BoolTensor
(
data
.
train_mask
)
labels
=
g
.
ndata
[
'label'
]
t
est
_mask
=
th
.
BoolTensor
(
data
.
test
_mask
)
t
rain
_mask
=
g
.
ndata
[
'train
_mask
'
]
g
=
DGLGraph
(
data
.
graph
)
test_mask
=
g
.
ndata
[
'test_mask'
]
return
g
,
features
,
labels
,
train_mask
,
test_mask
return
g
,
features
,
labels
,
train_mask
,
test_mask
###############################################################################
###############################################################################
...
...
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