You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/09/06 09:40:54 UTC
[GitHub] eldercrow commented on issue #7717: Subpixel convolution(state of art) implementation rather than using Deconvolution.
eldercrow commented on issue #7717: Subpixel convolution(state of art) implementation rather than using Deconvolution.
URL: https://github.com/apache/incubator-mxnet/issues/7717#issuecomment-327431788
As far as I know, mxnet does not support subpixel upsampling layer yet. Still, you can emulate it using a series of transpose and reshape layers. I am currently using the followings, messy but works anyway.
``` python
def subpixel_upsample(data, ch, c, r, name=None):
'''
Transform input data shape of (n, ch*r*c, h, w) to (n, ch, h*r, c*w).
ch: number of channels after upsample
r: row scale factor
c: column scale factor
'''
if r == 1 and c == 1:
return data
X = mx.sym.reshape(data=data, shape=(-3, 0, 0)) # (n*ch*r*c, h, w)
X = mx.sym.reshape(data=X, shape=(-4, -1, r * c, 0, 0)) # (n*ch, r*c, h, w)
X = mx.sym.transpose(data=X, axes=(0, 3, 2, 1)) # (n*ch, w, h, r*c)
X = mx.sym.reshape(data=X, shape=(0, 0, -1, c)) # (n*ch, w, h*r, c)
X = mx.sym.transpose(data=X, axes=(0, 2, 1, 3)) # (n*ch, h*r, w, c)
X = mx.sym.reshape(data=X, name=name, shape=(-4, -1, ch, 0, -3)) # (n, ch, h*r, w*c)
return X
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services