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

tf.data.array() cannot consume a Tensor, despite the documentation claiming so #8300

Open
AdmiralSnyder opened this issue Jun 10, 2024 · 6 comments
Assignees
Labels
comp:core type:bug Something isn't working

Comments

@AdmiralSnyder
Copy link

System information

  • windows 11, edge
  • TensorFlow.js -> script link to latest (as of 2024-06-10)
  • Browser version: 125.0.2535.92 (Official build) (64-bit)
  • Tensorflow.js Converter Version: N/A

Describe the current behavior
i am trying to create a dataset from a tensor, but that failed, see code:

Describe the expected behavior
the dataset should be create-able

Standalone code to reproduce the issue

let myTensor = tf.randomUniform([100], -2, 2); // returns a tensor as docs claim
// myTensor.print(); // prints the random data in this tensor
let myDataset = tf.data.array(myTensor); // returns something null-y - definitely not a dataset made from this tensor, 
console.log(myDataset); // outputs this: r {size: null}
@AdmiralSnyder AdmiralSnyder added the type:bug Something isn't working label Jun 10, 2024
@gaikwadrahul8 gaikwadrahul8 self-assigned this Jun 17, 2024
@gaikwadrahul8
Copy link
Contributor

Hi, @AdmiralSnyder

I apologize for the delayed response and I was trying to replicate the same behavior from my end with your code snippet and I'm getting same result for reference I have added screenshot below:

image

When I'm trying something like below it seems like working fine, if I've missed something here please let me know. Thank you for your cooperation and patience.

image

Copy link

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Jun 25, 2024
@AdmiralSnyder
Copy link
Author

Hey, the documentation clearly states that data.array should be able to consume a Tensor, rather than a Tensor[]:

image
Quote:
Parameters:
items (tf.void|number|string|TypedArray|tf.Tensor|tf.Tensor[]|{[key: string]:tf.Tensor|number|string}[]) An array of elements that will be parsed as items in a dataset.

which I read as:
data.array consumes these types of things:

  • tf.void
  • number
  • string
  • TypedArray
  • tf.Tensor --> a single tensor
  • tf.Tensor[] --> an array of tensors
  • an array of objects with key - value specifications where the key is a string and the value is either a tensor or a number or a string

-> and since the simple case where you enter the single tensor into the data.array function clearly doesn't work, this is either a bug in the implementation or in the documentation
-> the workaround of putting the tensor between square brackets is not acceptable.

@shmishra99
Copy link
Contributor

Hi @AdmiralSnyder ,

I apologize for the delayed response. The documentation for tf.data.array() clearly states that the expected parameter is an array, as you can see in the code here and the accompanying comment. It also describes this parameter as An array of elements that will be parsed as items in a dataset.

May be I'm misunderstanding your question. Could you please clarify what you're finding confusing?

Thank You!!

Copy link

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Sep 17, 2024
@AdmiralSnyder
Copy link
Author

Hi @shmishra99 my issue is with the documentation stating certain types vs. the documentation saying something (the stuff you quoted) in prose - there's a discrepancy there (or at least, there was at the point in time when i created this issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:core type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants