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

Tensor Display Implementation? #786

Open
zicklag opened this issue May 17, 2023 · 4 comments
Open

Tensor Display Implementation? #786

zicklag opened this issue May 17, 2023 · 4 comments

Comments

@zicklag
Copy link

zicklag commented May 17, 2023

Hey there! I'm a fairly new to machine learning, but I'm wanting to use dydx instead of PyTorch as I go through pieces of the d2l course.

One thing I feel would be nice to have is a display implementation for tensors that would print out the tensors in a way similar to the display from PyTorch or TensorFlow.

This may exist already and I just haven't found it, but both of the debug representations are extremely wordy and include implementation details that aren't helpful when just wanting to visualize a tensor.

If you're open to this and I stick with using dydx, I might find time to implement it.

@coreylowman
Copy link
Owner

Great idea, I love it! I think we could also implement display better for devices, which is semi-related to this.

Would be happy to help push forward any contributions related to this. You'd probably want to do something like:

  1. Convert the data to a Vec<E> using self.as_vec()
  2. Use self.strides to index in for the given amount of values you want to print out

I think pytorch prints out the first N and last N if the tensor is too big. We'd have to figure out what the limit is to print out the whole array.

@zicklag
Copy link
Author

zicklag commented May 19, 2023

Cool, I'm hoping to continue finding some time trying out dydx, and if so I'll work on the Display implementation probably for both Tensor and Device.

I'm really impressed with the ergonomics and elegance of the API so far, great work!

@coreylowman
Copy link
Owner

Thanks! And ideas/contributions like this will only help 😁

@emchristiansen
Copy link

FWIW you can get a pretty good string by using .array(), e.g. println("{#?}", my_tensor.array()).
The array will have the same structure as the tensor (it's not a 1D array).

Also, the project is dfdx, not dydx!

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

No branches or pull requests

3 participants