You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""The :class:`SubpixelConv2d` class is a sub-pixel 2d convolutional ayer, usually be used
2203
+
for Super-Resolution applications, `example code <https://github.com/zsdonghao/SRGAN/>`_.
2204
+
2205
+
Parameters
2206
+
------------
2207
+
net : TensorLayer layer.
2208
+
scale : int, upscaling ratio, a wrong setting will lead to Dimension size error.
2209
+
n_out_channel : int or None, the number of output channels.
2210
+
Note that, the number of input channels == (scale x scale) x The number of output channels.
2211
+
If None, automatically set n_out_channel == the number of input channels / (scale x scale).
2212
+
act : activation function.
2213
+
name : string.
2214
+
An optional name to attach to this layer.
2215
+
2216
+
Examples
2217
+
---------
2218
+
>>> # examples here just want to tell you how to set the n_out_channel.
2219
+
>>> x = np.random.rand(2, 16, 16, 4)
2220
+
>>> X = tf.placeholder("float32", shape=(2, 16, 16, 4), name="X")
2221
+
>>> net = InputLayer(X, name='input')
2222
+
>>> net = SubpixelConv2d(net, scale=2, n_out_channel=1, name='subpixel_conv2d')
2223
+
>>> y = sess.run(net.outputs, feed_dict={X: x})
2224
+
>>> print(x.shape, y.shape)
2225
+
... (2, 16, 16, 4) (2, 32, 32, 1)
2226
+
>>>
2227
+
>>> x = np.random.rand(2, 16, 16, 4*10)
2228
+
>>> X = tf.placeholder("float32", shape=(2, 16, 16, 4*10), name="X")
2229
+
>>> net = InputLayer(X, name='input2')
2230
+
>>> net = SubpixelConv2d(net, scale=2, n_out_channel=10, name='subpixel_conv2d2')
2231
+
>>> y = sess.run(net.outputs, feed_dict={X: x})
2232
+
>>> print(x.shape, y.shape)
2233
+
... (2, 16, 16, 40) (2, 32, 32, 10)
2234
+
>>>
2235
+
>>> x = np.random.rand(2, 16, 16, 25*10)
2236
+
>>> X = tf.placeholder("float32", shape=(2, 16, 16, 25*10), name="X")
2237
+
>>> net = InputLayer(X, name='input3')
2238
+
>>> net = SubpixelConv2d(net, scale=5, n_out_channel=None, name='subpixel_conv2d3')
2239
+
>>> y = sess.run(net.outputs, feed_dict={X: x})
2240
+
>>> print(x.shape, y.shape)
2241
+
... (2, 16, 16, 250) (2, 80, 80, 10)
2242
+
2243
+
References
2244
+
------------
2245
+
- `Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network <https://arxiv.org/pdf/1609.05158.pdf>`_
0 commit comments