Skip to content

[math] add ein_rearrange, ein_reduce, and ein_repeat functions#590

Merged
chaoming0625 merged 4 commits intomasterfrom
einops
Jan 9, 2024
Merged

[math] add ein_rearrange, ein_reduce, and ein_repeat functions#590
chaoming0625 merged 4 commits intomasterfrom
einops

Conversation

@chaoming0625
Copy link
Copy Markdown
Member

Examples:

import brainpy.math as bm

# rearrange elements according to the pattern
output_tensor = bm.ein_rearrange(input_tensor, 't b c -> b c t')
# combine rearrangement and reduction
output_tensor = bm.ein_reduce(input_tensor, 'b c (h h2) (w w2) -> b h w c', 'mean', h2=2, w2=2)
# copy along a new axis
output_tensor = bm.ein_repeat(input_tensor, 'h w -> h w c', c=3)

@chaoming0625 chaoming0625 merged commit fca558f into master Jan 9, 2024
@chaoming0625 chaoming0625 deleted the einops branch January 9, 2024 08:21
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.

1 participant