Skip to content

Commit fecf96e

Browse files
committed
[release] simplified conv1d
1 parent 966f320 commit fecf96e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

docs/modules/layers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ Layer list
288288
AtrousConv2dLayer
289289
SeparableConv2dLayer
290290

291+
Conv1d
291292
Conv2d
292293
DeConv2d
294+
293295
MaxPool1d
294296
MeanPool1d
295297
MaxPool2d
@@ -464,6 +466,10 @@ For users don't familiar with TensorFlow, the following simplified functions may
464466
We will provide more simplified functions later, but if you are good at TensorFlow, the professional
465467
APIs may better for you.
466468

469+
1D Convolutional layer
470+
^^^^^^^^^^^^^^^^^^^^^^^
471+
.. autofunction:: Conv1d
472+
467473
2D Convolutional layer
468474
^^^^^^^^^^^^^^^^^^^^^^^
469475
.. autofunction:: Conv2d

tensorlayer/layers.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,39 @@ def deconv2d_bilinear_upsampling_initializer(shape):
17911791
return bilinear_weights_init
17921792

17931793
## Convolutional layer (Simplified)
1794+
def Conv1d(net, n_filter=32, filter_size=5, stride=1, act=None,
1795+
padding='SAME', use_cudnn_on_gpu=None,data_format=None,
1796+
W_init = tf.truncated_normal_initializer(stddev=0.02),
1797+
b_init = tf.constant_initializer(value=0.0),
1798+
W_init_args = {}, b_init_args = {}, name ='conv1d',):
1799+
"""Wrapper for :class:`Conv1dLayer`, if you don't understand how to use :class:`Conv1dLayer`, this function may be easier.
1800+
1801+
Parameters
1802+
----------
1803+
net : TensorLayer layer.
1804+
n_filter : number of filter.
1805+
filter_size : an int.
1806+
stride : an int.
1807+
act : None or activation function.
1808+
others : see :class:`Conv1dLayer`.
1809+
"""
1810+
if act is None:
1811+
act = tf.identity
1812+
net = Conv1dLayer(layer = net,
1813+
act = act,
1814+
shape = [filter_size, int(net.outputs.get_shape()[-1]), n_filter],
1815+
stride = stride,
1816+
padding = padding,
1817+
use_cudnn_on_gpu = use_cudnn_on_gpu,
1818+
data_format = data_format,
1819+
W_init = W_init,
1820+
b_init = b_init,
1821+
W_init_args = W_init_args,
1822+
b_init_args = b_init_args,
1823+
name = name,
1824+
)
1825+
return net
1826+
17941827
def Conv2d(net, n_filter=32, filter_size=(3, 3), strides=(1, 1), act = None,
17951828
padding='SAME', W_init = tf.truncated_normal_initializer(stddev=0.02), b_init = tf.constant_initializer(value=0.0),
17961829
W_init_args = {}, b_init_args = {}, name ='conv2d',):

0 commit comments

Comments
 (0)