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
fd7b6a52
Unverified
Commit
fd7b6a52
authored
Dec 18, 2020
by
Wissam Antoun
Committed by
GitHub
Dec 18, 2020
Browse files
fixed JSON error in run_qa with fp16 (#9186)
parent
66a14a2f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
examples/question-answering/utils_qa.py
examples/question-answering/utils_qa.py
+2
-2
No files found.
examples/question-answering/utils_qa.py
View file @
fd7b6a52
...
...
@@ -206,7 +206,7 @@ def postprocess_qa_predictions(
# Make `predictions` JSON-serializable by casting np.float back to float.
all_nbest_json
[
example
[
"id"
]]
=
[
{
k
:
(
float
(
v
)
if
isinstance
(
v
,
(
np
.
float32
,
np
.
float64
))
else
v
)
for
k
,
v
in
pred
.
items
()}
{
k
:
(
float
(
v
)
if
isinstance
(
v
,
(
np
.
float16
,
np
.
float32
,
np
.
float64
))
else
v
)
for
k
,
v
in
pred
.
items
()}
for
pred
in
predictions
]
...
...
@@ -394,7 +394,7 @@ def postprocess_qa_predictions_with_beam_search(
# Make `predictions` JSON-serializable by casting np.float back to float.
all_nbest_json
[
example
[
"id"
]]
=
[
{
k
:
(
float
(
v
)
if
isinstance
(
v
,
(
np
.
float32
,
np
.
float64
))
else
v
)
for
k
,
v
in
pred
.
items
()}
{
k
:
(
float
(
v
)
if
isinstance
(
v
,
(
np
.
float16
,
np
.
float32
,
np
.
float64
))
else
v
)
for
k
,
v
in
pred
.
items
()}
for
pred
in
predictions
]
...
...
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