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
5bf9caa0
Unverified
Commit
5bf9caa0
authored
May 22, 2024
by
Lu Teng
Committed by
GitHub
May 21, 2024
Browse files
Fix inhomogeneous shape error in example (#30434)
Fix inhomogeneous shape error in example.
parent
d24097e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
examples/flax/question-answering/run_qa.py
examples/flax/question-answering/run_qa.py
+2
-3
No files found.
examples/flax/question-answering/run_qa.py
View file @
5bf9caa0
...
@@ -426,7 +426,8 @@ def eval_data_collator(dataset: Dataset, batch_size: int):
...
@@ -426,7 +426,8 @@ def eval_data_collator(dataset: Dataset, batch_size: int):
for
idx
in
batch_idx
:
for
idx
in
batch_idx
:
batch
=
dataset
[
idx
]
batch
=
dataset
[
idx
]
batch
=
{
k
:
np
.
array
(
v
)
for
k
,
v
in
batch
.
items
()}
# Ignore `offset_mapping` to avoid numpy/JAX array conversion issue.
batch
=
{
k
:
np
.
array
(
v
)
for
k
,
v
in
batch
.
items
()
if
k
!=
"offset_mapping"
}
yield
batch
yield
batch
...
@@ -1000,7 +1001,6 @@ def main():
...
@@ -1000,7 +1001,6 @@ def main():
position
=
2
,
position
=
2
,
):
):
_
=
batch
.
pop
(
"example_id"
)
_
=
batch
.
pop
(
"example_id"
)
_
=
batch
.
pop
(
"offset_mapping"
)
predictions
=
pad_shard_unpad
(
p_eval_step
)(
predictions
=
pad_shard_unpad
(
p_eval_step
)(
state
,
batch
,
min_device_batch
=
per_device_eval_batch_size
state
,
batch
,
min_device_batch
=
per_device_eval_batch_size
)
)
...
@@ -1055,7 +1055,6 @@ def main():
...
@@ -1055,7 +1055,6 @@ def main():
eval_loader
,
total
=
math
.
ceil
(
len
(
eval_dataset
)
/
eval_batch_size
),
desc
=
"Evaluating ..."
,
position
=
2
eval_loader
,
total
=
math
.
ceil
(
len
(
eval_dataset
)
/
eval_batch_size
),
desc
=
"Evaluating ..."
,
position
=
2
):
):
_
=
batch
.
pop
(
"example_id"
)
_
=
batch
.
pop
(
"example_id"
)
_
=
batch
.
pop
(
"offset_mapping"
)
predictions
=
pad_shard_unpad
(
p_eval_step
)(
state
,
batch
,
min_device_batch
=
per_device_eval_batch_size
)
predictions
=
pad_shard_unpad
(
p_eval_step
)(
state
,
batch
,
min_device_batch
=
per_device_eval_batch_size
)
start_logits
=
np
.
array
(
predictions
[
0
])
start_logits
=
np
.
array
(
predictions
[
0
])
end_logits
=
np
.
array
(
predictions
[
1
])
end_logits
=
np
.
array
(
predictions
[
1
])
...
...
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