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
466a9654
Commit
466a9654
authored
Jun 01, 2019
by
VictorSanh
Browse files
fix bug/typos
parent
c198ff5f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
hubconfs/transformer_xl_hubconf.py
hubconfs/transformer_xl_hubconf.py
+2
-2
No files found.
hubconfs/transformer_xl_hubconf.py
View file @
466a9654
...
...
@@ -86,7 +86,7 @@ def transformerXLModel(*args, **kwargs):
# We can re-use the memory cells in a subsequent call to attend a longer context
>>> with torch.no_grad():
hidden_states_1, mems_1 = model(tokens_tensor_1)
hidden_states_2,
past
= model(tokens_tensor_2,
past=past
)
hidden_states_2,
mems_2
= model(tokens_tensor_2,
mems=mems_1
)
"""
model
=
TransfoXLModel
.
from_pretrained
(
*
args
,
**
kwargs
)
return
model
...
...
@@ -121,7 +121,7 @@ def transformerXLLMHeadModel(*args, **kwargs):
# We can re-use the memory cells in a subsequent call to attend a longer context
>>> with torch.no_grad():
predictions_1, mems_1 = model(tokens_tensor_1)
predictions_2,
past
= model(tokens_tensor_2,
past=past
)
predictions_2,
mems_2
= model(tokens_tensor_2,
mems=mems_1
)
# Get the predicted last token
>>> predicted_index = torch.argmax(predictions_2[0, -1, :]).item()
...
...
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