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
4edde000
Unverified
Commit
4edde000
authored
Aug 19, 2020
by
xiang song(charlie.song)
Committed by
GitHub
Aug 19, 2020
Browse files
Fix tree lstm (#2052)
Co-authored-by:
Ubuntu
<
ubuntu@ip-172-31-63-129.ec2.internal
>
parent
c8a44c78
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
0 deletions
+6
-0
examples/mxnet/tree_lstm/README.md
examples/mxnet/tree_lstm/README.md
+3
-0
examples/mxnet/tree_lstm/tree_lstm.py
examples/mxnet/tree_lstm/tree_lstm.py
+2
-0
python/dgl/data/tree.py
python/dgl/data/tree.py
+1
-0
No files found.
examples/mxnet/tree_lstm/README.md
View file @
4edde000
...
...
@@ -27,3 +27,6 @@ DGLBACKEND=mxnet python3 train.py --gpu 0
## Speed Test
See https://docs.google.com/spreadsheets/d/1eCQrVn7g0uWriz63EbEDdes2ksMdKdlbWMyT8PSU4rc .
## Note
The code can work with MXNet 1.5.1
examples/mxnet/tree_lstm/tree_lstm.py
View file @
4edde000
...
...
@@ -96,6 +96,7 @@ class TreeLSTM(gluon.nn.Block):
self
.
linear
=
gluon
.
nn
.
Dense
(
num_classes
)
cell
=
TreeLSTMCell
if
cell_type
==
'nary'
else
ChildSumTreeLSTMCell
self
.
cell
=
cell
(
x_size
,
h_size
)
self
.
ctx
=
ctx
def
forward
(
self
,
batch
,
h
,
c
):
"""Compute tree-lstm prediction given a batch.
...
...
@@ -113,6 +114,7 @@ class TreeLSTM(gluon.nn.Block):
The prediction of each node.
"""
g
=
batch
.
graph
g
=
g
.
to
(
self
.
ctx
)
# feed embedding
embeds
=
self
.
embedding
(
batch
.
wordid
*
batch
.
mask
)
wiou
=
self
.
cell
.
W_iou
(
self
.
dropout
(
embeds
))
...
...
python/dgl/data/tree.py
View file @
4edde000
...
...
@@ -214,6 +214,7 @@ class SSTDataset(DGLBuiltinDataset):
self
.
_trees
=
load_graphs
(
graph_path
)[
0
]
self
.
_vocab
=
load_info
(
vocab_path
)[
'vocab'
]
self
.
_pretrained_emb
=
None
if
os
.
path
.
exists
(
emb_path
):
self
.
_pretrained_emb
=
load_info
(
emb_path
)[
'embed'
]
...
...
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