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

How to implement pixelshuffle with tensorflow #2

Open
52gentleman opened this issue Dec 1, 2020 · 1 comment
Open

How to implement pixelshuffle with tensorflow #2

52gentleman opened this issue Dec 1, 2020 · 1 comment

Comments

@52gentleman
Copy link

How to implement pixelshuffle with tensorflow,thank you

@fangwei123456
Copy link
Owner

fangwei123456 commented Dec 4, 2020

I don't know much about TensorFlow. But I think you can implement pixelunshuffle with TF by referencing this code:
pytorch/pytorch#2456

out_channel = c*(r**2)
out_h = h//r
out_w = w//r
fm_view = fm.contiguous().view(b, c, out_h, r, out_w, r)
fm_prime = fm_view.permute(0,1,3,5,2,4).contiguous().view(b,out_channel, out_h, out_w)

This code uses PyTorch's functions view and permute. There are also similar functions in TF:
https://www.tensorflow.org/api_docs/python/tf/keras/layers/Permute
https://www.tensorflow.org/api_docs/python/tf/reshape

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

No branches or pull requests

2 participants