Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
6cd76995
Commit
6cd76995
authored
Feb 09, 2019
by
thomwolf
Browse files
update transfo xl example
parent
1320e4ec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
examples/run_transfo_xl.py
examples/run_transfo_xl.py
+3
-3
pytorch_pretrained_bert/modeling_transfo_xl_utilities.py
pytorch_pretrained_bert/modeling_transfo_xl_utilities.py
+1
-1
No files found.
examples/run_transfo_xl.py
View file @
6cd76995
...
...
@@ -28,7 +28,7 @@ import math
import
torch
from
pytorch_pretrained_bert
import
TransfoXLModel
,
TransfoXLCorpus
from
pytorch_pretrained_bert
import
TransfoXL
LMHead
Model
,
TransfoXLCorpus
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(name)s - %(message)s'
,
datefmt
=
'%m/%d/%Y %H:%M:%S'
,
...
...
@@ -79,7 +79,7 @@ def main():
device
=
device
,
ext_len
=
args
.
ext_len
)
# Load a pre-trained model
model
=
TransfoXLModel
.
from_pretrained
(
args
.
model_name
)
model
=
TransfoXL
LMHead
Model
.
from_pretrained
(
args
.
model_name
)
model
=
model
.
to
(
device
)
logger
.
info
(
'Evaluating with bsz {} tgt_len {} ext_len {} mem_len {} clamp_len {}'
.
format
(
...
...
pytorch_pretrained_bert/modeling_transfo_xl_utilities.py
View file @
6cd76995
...
...
@@ -169,7 +169,7 @@ class ProjectedAdaptiveLogSoftmax(nn.Module):
if
i
==
0
:
if
target
is
not
None
:
logprob_i
=
head_logprob_i
.
gather
(
1
,
target_i
[:,
None
]).
squeeze
(
1
)
logprob_i
=
head_logprob_i
.
gather
(
1
,
target_i
[:,
None
]).
squeeze
(
1
)
else
:
out
[:,
:
self
.
cutoffs
[
0
]]
=
head_logprob
[:,
:
self
.
cutoffs
[
0
]]
else
:
...
...
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