Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Datasets] Add from_tf #29591

Merged
merged 9 commits into from
Nov 8, 2022
Merged

Conversation

bveeramani
Copy link
Member

@bveeramani bveeramani commented Oct 23, 2022

Signed-off-by: Balaji [email protected]

Blocked on

Why are these changes needed?

Parity with from_huggingface. Also, SimpleTensorflowDatasource is clunky. For more motivation, read #29430.

Related issue number

Towards #29430. See also #29589.

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@bveeramani bveeramani marked this pull request as ready for review November 2, 2022 21:44
@@ -1326,6 +1327,58 @@ def convert(ds: "datasets.Dataset") -> Dataset[ArrowRow]:
)


@PublicAPI
def from_tf(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expand this?

Suggested change
def from_tf(
def from_tensorflow(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a method called Dataset.to_tf. I prefer tensorflow over tf, but we should be consistent.

What do you think? We could always rename Dataset.to_tf to Dataset.to_tensorflow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right... Maybe we can:

  1. Name this from_tensorflow.
  2. Create a to_tensorflow.
  3. Have to_tf redirect to to_tensorflow and eventually deprecate it.

But will leave to folks like @clarkzinzow @c21 to make the call here.

Copy link
Contributor

@clarkzinzow clarkzinzow Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd actually vote for renaming these to from_tf_dataset, to_tf_dataset, from_torch_dataset, to_torch_dataset, etc. This is less ambiguous ("Am I getting a TensorFlow tensor or dataset with this API?"), discoverable, and better matches what the rest of the ecosystem is doing, e.g. HuggingFace and Petastorm.

I think that tf is a common enough shorthand that we shouldn't expand it to tensorflow, but happy to hear others' opinions, and maybe we can do a quick ecosystem check to verify this.

Copy link
Contributor

@clarkzinzow clarkzinzow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -1326,6 +1327,58 @@ def convert(ds: "datasets.Dataset") -> Dataset[ArrowRow]:
)


@PublicAPI
def from_tf(
Copy link
Contributor

@clarkzinzow clarkzinzow Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd actually vote for renaming these to from_tf_dataset, to_tf_dataset, from_torch_dataset, to_torch_dataset, etc. This is less ambiguous ("Am I getting a TensorFlow tensor or dataset with this API?"), discoverable, and better matches what the rest of the ecosystem is doing, e.g. HuggingFace and Petastorm.

I think that tf is a common enough shorthand that we shouldn't expand it to tensorflow, but happy to hear others' opinions, and maybe we can do a quick ecosystem check to verify this.

Returns:
A :class:`Dataset` that contains the samples stored in the TensorFlow dataset.
""" # noqa: E501
return from_items(list(dataset.as_numpy_iterator()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misc. thing to note that I hit before in tests: .as_numpy_iterator() doesn't work with ragged tensors. tensorflow/tensorflow#53149

@clarkzinzow clarkzinzow merged commit bbd5b9c into ray-project:master Nov 8, 2022
WeichenXu123 pushed a commit to WeichenXu123/ray that referenced this pull request Dec 19, 2022
Parity with from_huggingface. Also, SimpleTensorflowDatasource is clunky. For more motivation, read ray-project#29430.

Signed-off-by: Weichen Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants