Skip to content

Rearrange to reshape and permute? #218

Answered by arogozhnikov
camenduru asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @camenduru

You can think of it in steps:

# first transpose: b c h w -> b h w c
x = x.transpose([0, 2, 3, 1])

# then compose two axes into one: b h w c-> b (h w) c
b, h, w, c = x.shape
x = x.reshape([b,  h * w, c])

stackoverflow is the right place for such questions

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@camenduru
Comment options

Answer selected by camenduru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants