4 ms·
I think einsum is great but it's a bit like regex in that it's unnecessarily concise and hard to read. I use a wrapper where you can name the axes anything you
by chpatrick 2y ago
I think einsum is great but it's a bit like regex in that it's unnecessarily concise and hard to read. I use a wrapper where you can name the axes anything you like, eg. "index", "world", "cam", and it translates it to the single letters.
Even better is if the library keeps track of the names of the tensor axes and the einsum is automatic.
- WCSTombs 2y agoI totally agree. Here's a library that basically does that: https://docs.xarray.dev/en/stable/ https://docs.xarray.dev/en/stable/
- rsfern 2y agoNot sure if the wrapper you’re talking about is your own custom code, but I really like using einops lately. It’s got similar axis naming capabilities and it dispatches to both numpy and pytorch http://einops.rocks/ http://einops.rocks/
- chpatrick 2y agoI just made my own function but that sounds great, I'll check it out!