tensorflow / tensorflow/datasets

mock_data fails for "coco_captions" dataset

Open
#4,125 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
4.6k
Forks
1.6k
Avg merge
3h 54m
Merged PRs (30d)
1

Description

Short description
tfds.testing.mock_data fails for "coco_captions" dataset due to the Sequence features.

Environment information
Google internal test infra running code synched to Sep 8, 4:35 PM PDT.

Reproduction instructions

This runs as expected

builder = tfds.builder("coco_captions")
dataset = builder.as_dataset(split="train", decoders={"image": tfds.decode.SkipDecoding()})
x = next(iter(dataset))

As does this

with tfds.testing.mock_data(num_examples=50):
      builder = tfds.builder('mnist')
      dataset = builder.as_dataset(
          split='train', decoders={'image': tfds.decode.SkipDecoding()})
      x = next(iter(dataset))

However, this fails

with tfds.testing.mock_data(num_examples=50):
  builder = tfds.builder("coco_captions")
  dataset = builder.as_dataset(split="train", decoders={"image": tfds.decode.SkipDecoding()})
  x = next(iter(dataset))

With

deterministic_test.py:63 in test_deterministic_script
    x = next(iter(train_ds))
tensorflow/python/data/ops/iterator_ops.py:787 in __next__
    return self._next_internal()
tensorflow/python/data/ops/iterator_ops.py:770 in _next_internal
    ret = gen_dataset_ops.iterator_get_next(
tensorflow/python/ops/gen_dataset_ops.py:3017 in iterator_get_next
    _ops.raise_from_not_ok_status(e, name)
tensorflow/python/framework/ops.py:7215 in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__IteratorGetNext_output_types_11_device_/job:localhost/replica:0/task:0/device:CPU:0}} ValueError: In <Sequence> with name "objects":
The length of all elements of one sequence should be the same. Got 5 != 7

Sometimes (seemingly non-deterministically) the error is

ValueError: In <Sequence> with name "captions":
The length of all elements of one sequence should be the same. Got 49 != 37

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported reproduction using tfds.testing.mock_data and the coco_captions builder, then inspect how mock_data handles Sequence features such as objects and captions. Done means the reproduction can iterate deterministically without inconsistent sequence-length errors, while the existing mnist behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
data, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.