"vscode:/vscode.git/clone" did not exist on "e58cbed51d1a4877e37b2fcf23e8d801b233ec4d"
Unverified Commit 5bf9caa0 authored by Lu Teng's avatar Lu Teng Committed by GitHub
Browse files

Fix inhomogeneous shape error in example (#30434)

Fix inhomogeneous shape error in example.
parent d24097e0
......@@ -426,7 +426,8 @@ def eval_data_collator(dataset: Dataset, batch_size: int):
for idx in batch_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
......@@ -1000,7 +1001,6 @@ def main():
position=2,
):
_ = 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
)
......@@ -1055,7 +1055,6 @@ def main():
eval_loader, total=math.ceil(len(eval_dataset) / eval_batch_size), desc="Evaluating ...", position=2
):
_ = 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)
start_logits = np.array(predictions[0])
end_logits = np.array(predictions[1])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment