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
a31e591d
Commit
a31e591d
authored
Sep 23, 2019
by
thomwolf
Browse files
fix XLM tests
parent
447de34d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
pytorch_transformers/modeling_xlm.py
pytorch_transformers/modeling_xlm.py
+1
-1
pytorch_transformers/tests/modeling_xlm_test.py
pytorch_transformers/tests/modeling_xlm_test.py
+1
-1
No files found.
pytorch_transformers/modeling_xlm.py
View file @
a31e591d
...
@@ -566,7 +566,7 @@ class XLMPredLayer(nn.Module):
...
@@ -566,7 +566,7 @@ class XLMPredLayer(nn.Module):
scores
=
self
.
proj
(
x
)
scores
=
self
.
proj
(
x
)
outputs
=
(
scores
,)
+
outputs
outputs
=
(
scores
,)
+
outputs
if
y
is
not
None
:
if
y
is
not
None
:
loss
=
F
.
cross_entropy
(
scores
.
view
(
-
1
,
self
.
n_words
),
y
,
reduction
=
'elementwise_mean'
)
loss
=
F
.
cross_entropy
(
scores
.
view
(
-
1
,
self
.
n_words
),
y
.
view
(
-
1
)
,
reduction
=
'elementwise_mean'
)
outputs
=
(
loss
,)
+
outputs
outputs
=
(
loss
,)
+
outputs
else
:
else
:
scores
=
self
.
proj
.
log_prob
(
x
)
scores
=
self
.
proj
.
log_prob
(
x
)
...
...
pytorch_transformers/tests/modeling_xlm_test.py
View file @
a31e591d
...
@@ -185,7 +185,7 @@ class XLMModelTest(CommonTestCases.CommonModelTester):
...
@@ -185,7 +185,7 @@ class XLMModelTest(CommonTestCases.CommonModelTester):
model
.
eval
()
model
.
eval
()
outputs
=
model
(
input_ids
)
outputs
=
model
(
input_ids
)
start_top_log_probs
,
start_top_index
,
end_top_log_probs
,
end_top_index
,
cls_logits
,
mems
=
outputs
start_top_log_probs
,
start_top_index
,
end_top_log_probs
,
end_top_index
,
cls_logits
=
outputs
outputs
=
model
(
input_ids
,
start_positions
=
sequence_labels
,
outputs
=
model
(
input_ids
,
start_positions
=
sequence_labels
,
end_positions
=
sequence_labels
,
end_positions
=
sequence_labels
,
...
...
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