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
cd6d1138
Unverified
Commit
cd6d1138
authored
Nov 24, 2021
by
Rhett Ying
Committed by
GitHub
Nov 24, 2021
Browse files
[BugFix] fix dimension unmatch issue and legacy issue of torchtext (#3539)
parent
4bf70f09
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
examples/pytorch/pinsage/layers.py
examples/pytorch/pinsage/layers.py
+1
-1
examples/pytorch/pinsage/model.py
examples/pytorch/pinsage/model.py
+3
-3
No files found.
examples/pytorch/pinsage/layers.py
View file @
cd6d1138
...
...
@@ -171,7 +171,7 @@ class ItemToItemScorer(nn.Module):
super
().
__init__
()
n_nodes
=
full_graph
.
number_of_nodes
(
ntype
)
self
.
bias
=
nn
.
Parameter
(
torch
.
zeros
(
n_nodes
))
self
.
bias
=
nn
.
Parameter
(
torch
.
zeros
(
n_nodes
,
1
))
def
_add_bias
(
self
,
edges
):
bias_src
=
self
.
bias
[
edges
.
src
[
dgl
.
NID
]]
...
...
examples/pytorch/pinsage/model.py
View file @
cd6d1138
...
...
@@ -52,13 +52,13 @@ def train(dataset, args):
fields
=
{}
examples
=
[]
for
key
,
texts
in
item_texts
.
items
():
fields
[
key
]
=
torchtext
.
data
.
Field
(
include_lengths
=
True
,
lower
=
True
,
batch_first
=
True
)
fields
[
key
]
=
torchtext
.
legacy
.
data
.
Field
(
include_lengths
=
True
,
lower
=
True
,
batch_first
=
True
)
for
i
in
range
(
g
.
number_of_nodes
(
item_ntype
)):
example
=
torchtext
.
data
.
Example
.
fromlist
(
example
=
torchtext
.
legacy
.
data
.
Example
.
fromlist
(
[
item_texts
[
key
][
i
]
for
key
in
item_texts
.
keys
()],
[(
key
,
fields
[
key
])
for
key
in
item_texts
.
keys
()])
examples
.
append
(
example
)
textset
=
torchtext
.
data
.
Dataset
(
examples
,
fields
)
textset
=
torchtext
.
legacy
.
data
.
Dataset
(
examples
,
fields
)
for
key
,
field
in
fields
.
items
():
field
.
build_vocab
(
getattr
(
textset
,
key
))
#field.build_vocab(getattr(textset, key), vectors='fasttext.simple.300d')
...
...
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