tensorflow / tensorflow/datasets
Under mock_data, a trivial decoder changes the output tensor
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 1.6k
- Avg merge
- 3h 54m
- Merged PRs (30d)
- 1
Description
Short description
When tfds.testing.mock_data is active, passing a custom decoder to tfds.load alters the result, even if the decoder doesn't actually change the decoding logic.
Environment information
-
Operating System: Ubuntu 18.04
-
Python version: 3.7.5
-
tensorflow-datasets/tfds-nightlyversion: tensorflow-datasets 4.5.2 -
tensorflow/tf-nightlyversion: tensorflow 2.7.0 -
Does the issue still exists with the last
tfds-nightlypackage (pip install --upgrade tfds-nightly) ? Yes
Reproduction instructions
import contextlib
import tensorflow as tf
import tensorflow_datasets as tfds
@tfds.decode.make_decoder()
def no_op_decoder(example, feature):
return feature.decode_example(example)
with tfds.testing.mock_data():
#with contextlib.nullcontext():
ds = tfds.load('imagenet_v2', split='test')
image1 = next(iter(ds))['image']
ds = tfds.load('imagenet_v2', split='test',
decoders={'image': no_op_decoder()})
image2 = next(iter(ds))['image']
print(tf.reduce_all(image1 == image2).numpy())
Running this prints False, but if you comment the mock_data line and uncomment the nullcontext line, it prints True.
Link to logs
N/A
Expected behavior
It should print True in both cases.
Additional context
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the tfds.testing.mock_data context, tfds.load, and the tfds.decode.make_decoder entry points shown in the reproduction. Compare the two loading paths and add or run a regression test using the no-op decoder; done means both paths produce equal image tensors, as the example expects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- data, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100