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
chenpangpang
transformers
Commits
29c36e9f
Unverified
Commit
29c36e9f
authored
Jun 10, 2020
by
songyouwei
Committed by
GitHub
Jun 09, 2020
Browse files
run_pplm.py bug fix (#4867)
`is_leaf` may become `False` after `.to(device=device)` function call.
parent
13aa1741
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
examples/text-generation/pplm/run_pplm.py
examples/text-generation/pplm/run_pplm.py
+3
-0
No files found.
examples/text-generation/pplm/run_pplm.py
View file @
29c36e9f
...
...
@@ -148,6 +148,9 @@ def perturb_past(
for
i
in
range
(
num_iterations
):
print
(
"Iteration "
,
i
+
1
)
curr_perturbation
=
[
torch
.
from_numpy
(
p_
).
requires_grad_
(
True
).
to
(
device
=
device
)
for
p_
in
grad_accumulator
]
# make sure p_.grad is not None
for
p_
in
curr_perturbation
:
p_
.
retain_grad
()
# Compute hidden using perturbed past
perturbed_past
=
list
(
map
(
add
,
past
,
curr_perturbation
))
...
...
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