This interface is used to construct a callable object of the ``Conv1DPoolLayer`` class.The ``Conv1DPoolLayer`` is composed of a ``Conv2D`` and a ``Pool2D`` .
This interface is used to construct a callable object of the ``Conv1DPoolLayer`` class.
For more details, refer to code examples.The ``Conv1DPoolLayer`` layer calculates the output based on the input, filter and strides, paddings, dilations,
The ``Conv1DPoolLayer`` class does a ``Conv1D`` and a ``Pool1D`` .For more details,
groups,global_pooling, pool_type,ceil_mode,exclusive parameters.Input and Output are in NCH format, where N is batch size, C is the number of the feature map,
refer to code examples.The ``Conv1DPoolLayer`` layer calculates the output based on the
H is the height of the feature map.The data type of Input data and Output data is 'float32' or 'float64'.
input, filter and strides, paddings, dilations, groups,global_pooling, pool_type,ceil_mode,
exclusive parameters.
Args:
Parameters:
input(Variable):3-D Tensor, shape is [N, C, H], data type can be float32 or float64
input(Variable):3-D Tensor, shape is [N, C, H], data type can be float32 or float64
num_channels(int): The number of channels in the input data.
num_channels(int): The number of channels in the input data.
num_filters(int): The number of filters. It is the same as the output channels.
num_filters(int): The number of filters. It is the same as the output channels.
...
@@ -1915,147 +1917,174 @@ class Conv1dPoolLayer(Layer):
...
@@ -1915,147 +1917,174 @@ class Conv1dPoolLayer(Layer):
pool_stride (int): The stride size of the pool layer in Conv1DPoolLayer. Default: 1
pool_stride (int): The stride size of the pool layer in Conv1DPoolLayer. Default: 1
conv_padding (int): The padding size of the conv Layer in Conv1DPoolLayer. Default: 0
conv_padding (int): The padding size of the conv Layer in Conv1DPoolLayer. Default: 0
pool_padding (int): The padding of pool layer in Conv1DPoolLayer. Default: 0
pool_padding (int): The padding of pool layer in Conv1DPoolLayer. Default: 0
pool_type (str): Pooling type can be `max` for max-pooling or `avg` for average-pooling. Default: math:`max`
pool_type (str): Pooling type can be `max` for max-pooling or `avg` for average-pooling.
global_pooling (bool): Whether to use the global pooling. If global_pooling = true, pool_size and pool_padding while be ignored. Default: False
Default: math:`max`
global_pooling (bool): Whether to use the global pooling. If global_pooling = true,
pool_size and pool_padding while be ignored. Default: False
dilation (int): The dilation size of the conv Layer. Default: 1.
dilation (int): The dilation size of the conv Layer. Default: 1.
groups (int): The groups number of the conv Layer. According to grouped convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
groups (int): The groups number of the conv Layer. According to grouped convolution in
the first half of the filters is only connected to the first half of the input channels, while the second half of the filters is only
Alex Krizhevsky's Deep CNN paper: when group=2, the first half of the filters is
connected to the second half of the input channels. Default: 1.
only connected to the first half of the input channels, while the second half
param_attr (ParamAttr|None): The parameter attribute for learnable parameters/weights of conv layer. If it is set to None or one attribute of
of the filters is only connected to the second half of the input channels.
ParamAttr, conv2d will create ParamAttr as param_attr. If the Initializer of the param_attr is not set, the parameter is initialized
Default: 1.
with :`Normal(0.0, std)`,and the :`std` is :`(\\frac{2.0 }{filter\_elem\_num})^{0.5}`.Default: None.
param_attr (ParamAttr|None): The parameter attribute for learnable parameters/weights
bias_attr (ParamAttr|bool|None): The parameter attribute for the bias of conv.If it is set to False, no bias will be added to the output units.
of conv layer. If it is set to None or one attribute of ParamAttr, conv2d will
If it is set to None or one attribute of ParamAttr, conv2d will create ParamAttr as bias_attr. If the Initializer of the bias_attr is not
create ParamAttr as param_attr. If the Initializer of the param_attr
set, the bias is initialized zero. Default: None.
is not set, the parameter is initialized with :`Normal(0.0, std)`,and
name(str, optional): The default value is None. Normally there is no need for user to set this property. Default: None
the :`std` is :`(\\frac{2.0 }{filter\_elem\_num})^{0.5}`.Default: None.
act (str): Activation type for conv layer, if it is set to None, activation is not appended. Default: None.
bias_attr (ParamAttr|bool|None): The parameter attribute for the bias of conv.If it
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn library is installed. Default: False
is set to False, no bias will be added to the output units.If it is set to
ceil_mode (bool, optional): Whether to use the ceil function to calculate output height and width.
None or one attribute of ParamAttr, conv2d will create ParamAttr as bias_attr.
False is the default. If it is set to False, the floor function will be used. Default: False.
If the Initializer of the bias_attr is not set, the bias is initialized zero.
exclusive (bool, optional): Whether to exclude padding points in average pooling mode. Default: True.
Default: None.
act (str): Activation type for conv layer, if it is set to None, activation is not appended.
Return:
Default: None.
3-D Tensor, the result of input after conv and pool, with the same data type as :`input`
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn library
is installed. Default: False
Return Type:
ceil_mode (bool, optional): Whether to use the ceil function to calculate output
Variable
height and width.False is the default. If it is set to False, the floor function
will be used. Default: False.
exclusive (bool, optional): Whether to exclude padding points in average pooling mode.
Performs :Code:`Conv1dPoolLayer.forward` receives input data. After a conv and a pool,
the result will be output.
Parameters:
inputs(Variable): Inputs are 3-D Tensor, shape is [N, C, H] , where N is batch size,
C is the number of the feature map, H is the height of the feature map.The data
type of Input data is 'float32' or 'float64'.
Returns:
3-D Tensor, with the same data type as :`input`
"""
x=fluid.layers.unsqueeze(inputs,axes=[-1])
x=self._conv2d(x)
x=self._conv2d(x)
x=self._pool2d(x)
x=self._pool2d(x)
x=fluid.layers.squeeze(x,axes=[-1])
x=fluid.layers.squeeze(x,axes=[-1])
returnx
returnx
classCNNEncoder(Layer):
classCNNEncoder(Layer):
"""
"""
This interface is used to construct a callable object of the ``CNNEncoder`` class.The ``CNNEncoder`` is composed of a ``Embedding`` and a ``Conv1dPoolLayer`` .
This interface is used to construct a callable object of the ``CNNEncoder`` class.The ``CNNEncoder``
For more details, refer to code examples. The ``CNNEncoder`` layer calculates the output based on the input, dict_size and emb_dim, filter_size, num_filters,
is composed of ``Conv1dPoolLayer`` .``CNNEncoder`` can define every Conv1dPoolLayer with different
use_cuda, is_sparse, param_attr parameters. The type of Input data is a 3-D Tensor .The data type of Input data is 'float32'. Output data are in NCH
or same parameters. The ``Conv1dPoolLayer`` in ``CNNEncoder`` is parallel.The result of every
format, where N is batch size, C is the number of the feature map, H is the height of the feature map. The data type of Output data is 'float32' or 'float64'.
``Conv1dPoolLayer`` will concat as the final output.For more details, refer to code examples.
The ``CNNEncoder`` layer calculates the output based on the input, dict_size and emb_dim,
num_channels(int|list|tuple): The number of channels in the input data.If num_channels is a list or tuple, the length of num_channels must equal layer_num.If num_channels
is a int, all conv1dpoollayer's num_channels are the value of num_channels.
Parameters:
num_filters(int|list|tuple): The number of filters. It is the same as the output channels. If num_filters is a list or tuple, the length of num_filters must equal layer_num.If num_filters
num_channels(int|list|tuple): The number of channels in the input data.If num_channels is
is a int, all conv1dpoollayer's num_filters are the value of num_filters.
a list or tuple, the length of num_channels must equal layer_num.If num_channels
filter_size(int|list|tuple): The filter size of Conv1DPoolLayer in CNNEncoder. If filter_size is a list or tuple, the length of filter_size must equal layer_num.If filter_size
is a int, all conv1dpoollayer's num_channels are the value of num_channels.
is a int, all conv1dpoollayer's filter_size are the value of filter_size.
num_filters(int|list|tuple): The number of filters. It is the same as the output channels.
pool_size(int|list|tuple): The pooling size of Conv1DPoolLayer in CNNEncoder.If pool_size is a list or tuple, the length of pool_size must equal layer_num.If pool_size
If num_filters is a list or tuple, the length of num_filters must equal layer_num.
is a int, all conv1dpoollayer's pool_size are the value of pool_size.
If num_filters is a int, all conv1dpoollayer's num_filters are the value of num_filters.
layer_num(int): The number of conv1dpoolLayer used in CNNEncoder.
filter_size(int|list|tuple): The filter size of Conv1DPoolLayer in CNNEncoder. If filter_size
conv_stride(int|list|tuple): The stride size of the conv Layer in Conv1DPoolLayer. If conv_stride is a list or tuple, the length of conv_stride must equal layer_num.If conv_stride
is a list or tuple, the length of filter_size must equal layer_num.If filter_size is a
is a int, all conv1dpoollayer's conv_stride are the value of conv_stride. Default: 1
int, all conv1dpoollayer's filter_size are the value of filter_size.
pool_stride(int|list|tuple): The stride size of the pool layer in Conv1DPoolLayer. If pool_stride is a list or tuple, the length of pool_stride must equal layer_num.If pool_stride
pool_size(int|list|tuple): The pooling size of Conv1DPoolLayer in CNNEncoder.If pool_size is
is a int, all conv1dpoollayer's pool_stride are the value of pool_stride. Default: 1
a list or tuple, the length of pool_size must equal layer_num.If pool_size is a int,
conv_padding(int|list|tuple): The padding size of the conv Layer in Conv1DPoolLayer.If conv_padding is a list or tuple, the length of conv_padding must equal layer_num.If conv_padding
all conv1dpoollayer's pool_size are the value of pool_size.
is a int, all conv1dpoollayer's conv_padding are the value of conv_padding. Default: 0
layer_num(int): The number of conv1dpoolLayer used in CNNEncoder.
pool_padding(int|list|tuple): The padding of pool layer in Conv1DPoolLayer. If pool_padding is a list or tuple, the length of pool_padding must equal layer_num.If pool_padding
conv_stride(int|list|tuple): The stride size of the conv Layer in Conv1DPoolLayer. If
is a int, all conv1dpoollayer's pool_padding are the value of pool_padding. Default: 0
conv_stride is a list or tuple, the length of conv_stride must equal layer_num.
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn library is installed. Default: False
If conv_stride is a int, all conv1dpoollayer's conv_stride are the value of
act (str|list|tuple): Activation type for `Conv1dPoollayer` layer, if it is set to None, activation is not appended. Default: None.
conv_stride. Default: 1
pool_stride(int|list|tuple): The stride size of the pool layer in Conv1DPoolLayer. If
Return:
pool_stride is a list or tuple, the length of pool_stride must equal layer_num.
3-D Tensor, the result of input after embedding and conv1dPoollayer
If pool_stride is a int, all conv1dpoollayer's pool_stride are the value of
pool_stride. Default: 1
Return Type:
conv_padding(int|list|tuple): The padding size of the conv Layer in Conv1DPoolLayer.
Variable
If conv_padding is a list or tuple, the length of conv_padding must equal layer_num.
If conv_padding is a int, all conv1dpoollayer's conv_padding are the value of
conv_padding. Default: 0
pool_padding(int|list|tuple): The padding of pool layer in Conv1DPoolLayer. If pool_padding is
a list or tuple, the length of pool_padding must equal layer_num.If pool_padding is a
int, all conv1dpoollayer's pool_padding are the value of pool_padding. Default: 0
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn library is installed.
Default: False
act (str|list|tuple): Activation type for `Conv1dPoollayer` layer, if it is set to None,