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

Add dict syntax to the einops layers example #342

Merged
merged 4 commits into from
Sep 21, 2024

Conversation

eadadi
Copy link
Contributor

@eadadi eadadi commented Sep 21, 2024

This patch adds an example of the dict syntax that is given as argument in einops layers.

Why do we need this change?
I was trying to make an einops layer doing the following rearrange:

Rearrange('b (h w c) -> b h w c', h=64, w=64)

And had to read the source code to discover I have to use dict syntax to make it works:

Rearrange('b (h w c) -> b h w c', {'h'=64, 'w'=64})

So I believe that adding this example to the docs will make it easier for people like me

@arogozhnikov
Copy link
Owner

@eadadi

Rearrange('b (h w c) -> b h w c', h=64, w=64)  # works for almost all frameworks
Rearrange('b (h w c) -> b h w c', {'h': 64, 'w': 64}) # specific syntax for flax, because flax doesn't accept **kwargs

so no, this change is incorrect.

@eadadi
Copy link
Contributor Author

eadadi commented Sep 21, 2024

ok good to know. modified accordingly

@arogozhnikov arogozhnikov merged commit 8112f83 into arogozhnikov:main Sep 21, 2024
5 checks passed
@eadadi eadadi deleted the detail_dict_syntax branch September 21, 2024 19:30
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

Successfully merging this pull request may close these issues.

2 participants