-
Notifications
You must be signed in to change notification settings - Fork 44
Added the TensorCreation.java example #7
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
Conversation
|
Dear @karllessard could you have a look to this small PR? Could it be merged? |
karllessard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @zaleslaw , thanks for the PR! I like it overall, we need more of those. Just added a few comments and we are good to merge
tensorflow-examples/src/main/java/org/tensorflow/model/examples/tensors/TensorCreation.java
Show resolved
Hide resolved
| System.out.println("---- Scalar tensor ---------"); | ||
| System.out.println("DataType: " + rank0Tensor.dataType().name()); | ||
| System.out.println("Rank: " + rank0Tensor.data().rank()); | ||
| System.out.println("NumElements: " + rank0Tensor.data().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a user should access data() only when he's interested in doing some read/write operations to the tensor memory, as it might move the tensor from some remote location or from GPU memory to the local CPU for this purpose.
Therefore, if the user intent is only to display some metadata about the shape of the tensor, the tensor.shape() method is probably better. (rank0Tensor.shape().numDimensions() and rank0Tensor.shape().size() respectively in this case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but better to have rank() method in tensor interface for next different logic handling for tensors with the different rank
Agree, that maybe I should call methods on data() only for read/write purposes
tensorflow-examples/src/main/java/org/tensorflow/model/examples/tensors/TensorCreation.java
Show resolved
Hide resolved
|
@karllessard I'll fix and return. |
|
@karllessard fixed the review, please have a look |
karllessard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, I will probably add a bunch of more examples on how to create tensors because there is many other ways to do it
No description provided.