tensorflow / tensorflow/datasets
Support optional tensors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 1.6k
- Avg merge
- 3h 54m
- Merged PRs (30d)
- 1
Description
TF recently added optional support: https://www.tensorflow.org/api_docs/python/tf/experimental/Optional
It seems to be working inside tf.data:
ds = tf.data.Dataset.range(3)
ds = ds.map(lambda x: tf.experimental.Optional.from_value(x))
list(ds)[0].get_value()
We should update our feature connectors to accept None to return optionals. Maybe with a tfds.features.Optional like
def _info(self):
features=FeatureDict({
'image': tfds.features.Optional(tfds.features.Image()),
})
def _generate_examples(self):
yield {
'image': None, # Accept `None` or feature
}
Which would returns:
ds = tfds.load()
ds.element_spec = {'image': OptionalSpec(TensorSpec(shape=(None, None, 3), dtype=tf.uint8, name=None),)}
Not clear how this would translate into tf.train.Example spec though.
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 by reviewing TFDS feature connectors and the TensorFlow Optional API, then trace how feature values are represented in tf.train.Example. Determine the intended Optional connector behavior for None, including element_spec and serialization, and add coverage for accepted optional values once the representation is decided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- data, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100