Tensor `Display` Implementation?
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.
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:
- Convert the data to a
Vec<E>usingself.as_vec() - Use
self.stridesto 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.
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!
Thanks! And ideas/contributions like this will only help 😁
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!