[Feature suggestion] Operations on elements of a dimension
See original GitHub issueHello, I’m just throwing an idea, I’m not sure it fits in the scope of Einops, and it will probably require a lot of work, but I think it would be useful:
What about allowing to manipulate elements along a dimension, like for example the r,g,b channels of an image ? I could imagine a syntax that would look like this, with everything inside brackets referring to elements rather than dimensions:
# reorder color channels rgb to bgr OpenCV-style:
rearrange(imgs, 'batch [r g b] h w -> batch [b g r] h w')
Extending on the existing syntax, grouping elements would look like this:
# reorder color channels rgb to brg:
rearrange(imgs, 'batch [rg b] h w -> batch [b rg] h w', rg=2)
This could allow to drop elements:
# remove alpha channel:
rearrange(imgs, 'batch [rgb a] h w -> batch [rgb] h w', rgb=3)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Product dimensions - Dynamics 365 - Microsoft Learn
There are five product dimensions: color, configuration, size, style, and version. You combine product dimensions in dimension groups and assign ...
Read more >7 Ways to Prioritize Features and Product Improvements - Planio
Again, while this can be a powerful way to find features to prioritize, you want to make choices based on trends. Not individual...
Read more >Evidence that within-dimension features are generally ...
In this paper, we examine whether information about an item's category, provided by the same dimension type presented across multiple ...
Read more >Dimension, filter, and parameter types | Looker - Google Cloud
A dimension can only perform arithmetic on other dimensions, not measures. Additionally, type: number dimensions will not provide suggestions ...
Read more >Competing on the Eight Dimensions of Quality
I propose eight critical dimensions or categories of quality that can serve as a framework for strategic analysis: performance, features, reliability, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the
h[top bottom]
vs[top bottom]
part, I was trying to anticipate cases where you would also want to rearrange dimensions, likebecause I am not sure how hard it is to recognise dimensions based on content, and it may arguably be easier to see what the dimension represents.
Indeed, it may make sense to put that functionality in a new function to keep readability. But then how do we show in an obvious way on which dimension to operate ? Maybe something like this (for working on multiple dimensions at a time):
while forbidding to rearrange dimensions at the same time to keep the code clear and concerns separated ? with an
->
operator for potentially each dimension. (or we can keep the previous notation with a single arrow)If the function is made to only work on one axis at a time, there should be a clear way of stating which one. I don’t see a way of doing it without writing at least once all dimensions, with something like this:
einops.pack
andeinops.unpack
are the current way to manipulate a single dimension.They immediately cover chop and concatenation from this suggestion. As for reordering, it can be implemented with a combination unpack+pack.
You can find some closer-to-application examples here