Comments (1)
Well, if you look closely at the source code for PixelShuffle you would find out there isn't much difference between my implementation and pixelshuffle.
It is merely a matrix interlacing procedure.
From https://s0pytorch0org.icopy.site/docs/0.4.0/_modules/torch/nn/functional.html
def pixel_shuffle(input, upscale_factor):
r"""Rearranges elements in a tensor of shape :math:`[*, C*r^2, H, W]` to a
tensor of shape :math:`[C, H*r, W*r]`.
See :class:`~torch.nn.PixelShuffle` for details.
Args:
input (Tensor): Input
upscale_factor (int): factor to increase spatial resolution by
Examples::
>>> ps = nn.PixelShuffle(3)
>>> input = torch.empty(1, 9, 4, 4)
>>> output = ps(input)
>>> print(output.size())
torch.Size([1, 1, 12, 12])
"""
batch_size, channels, in_height, in_width = input.size()
channels //= upscale_factor ** 2
out_height = in_height * upscale_factor
out_width = in_width * upscale_factor
input_view = input.contiguous().view(
batch_size, channels, upscale_factor, upscale_factor,
in_height, in_width)
shuffle_out = input_view.permute(0, 1, 4, 2, 5, 3).contiguous()
return shuffle_out.view(batch_size, channels, out_height, out_width)
The general idea for nd to nd transformation usually involves using two operations:
- permute
- reshape
There is a great explanation here:
https://stackoverflow.com/questions/47977238/intuition-and-idea-behind-reshaping-4d-array-to-2d-array-in-numpy?noredirect=1&lq=1
from fast_dense_feature_extraction.
Related Issues (8)
- pytorch version sample_code.py run error HOT 11
- This fast dense feature extraction method (FDFE) seems not equal to the common one in terms of different receptive field. HOT 2
- Example code for standard architectures like ResNet? HOT 1
- Please check typo HOT 2
- dimensions of the ouput HOT 1
- what can i do if my custom basenet feature extractor does not use any maxpool2d layers?
- What is the purpose of multiConv?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast_dense_feature_extraction.