gilbert icon indicating copy to clipboard operation
gilbert copied to clipboard

Use this as an alternative for the `flatten()` function in Pytorch?

Open drupol opened this issue 4 months ago • 3 comments

Hello,

I’ve recently started new AI classes and I learned about PyTorch’s flatten() function, exploring its pros and cons. One of the notable issues is that the original function doesn't preserve spatial locality, which can be important in this contexts of AI and image processing.

This reminded me of the incredible @3blue1brown video on Hilbert curves (https://www.youtube.com/watch?v=3s7h2MHQtxc). I began wondering if there was an algorithm or method to flatten an image of any size with a Hilbert curve, preserving locality. And that’s what led me here.

Are you aware of an existing implementation for this and Pytorch, do you think this be a worthwhile feature to explore? The idea would be to use this algorithm to reshape a matrix into a simple vector.

Thank you!

Interesting reads:

  • https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136620717.pdf

drupol avatar Oct 20 '24 07:10 drupol