simple_img_conv_pool

paddle.fluid.nets. simple_img_conv_pool ( input, num_filters, filter_size, pool_size, pool_stride, pool_padding=0, pool_type='max', global_pooling=False, conv_stride=1, conv_padding=0, conv_dilation=1, conv_groups=1, param_attr=None, bias_attr=None, act=None, use_cudnn=True ) [source]
api_attr

Static Graph

The simple_img_conv_pool api is composed of api_fluid_layers_conv2d and api_fluid_layers_pool2d .

Parameters
  • input (Variable) – 4-D Tensor, shape is [N, C, H, W], data type can be float32 or float64.

  • num_filters (int) – The number of filters. It is the same as the output channels.

  • filter_size (int|list|tuple) – The filter size. If filter_size is a list or tuple, it must contain two integers, (filter_size_H, filter_size_W). Otherwise, the filter_size_H = filter_size_W = filter_size.

  • pool_size (int|list|tuple) – The pooling size of pool2d layer. If pool_size is a list or tuple, it must contain two integers, (pool_size_H, pool_size_W). Otherwise, the pool_size_H = pool_size_W = pool_size.

  • pool_stride (int|list|tuple) – The pooling stride of pool2d layer. If pool_stride is a list or tuple, it must contain two integers, (pooling_stride_H, pooling_stride_W). Otherwise, the pooling_stride_H = pooling_stride_W = pool_stride.

  • pool_padding (int|list|tuple) – The padding of pool2d layer. If pool_padding is a list or tuple, it must contain two integers, (pool_padding_H, pool_padding_W). Otherwise, the pool_padding_H = pool_padding_W = pool_padding. Default 0.

  • pool_type (str) – Pooling type can be max for max-pooling or avg for average-pooling. Default max.

  • global_pooling (bool) – Whether to use the global pooling. If global_pooling = true, pool_size and pool_padding while be ignored. Default False

  • conv_stride (int|list|tuple) – The stride size of the conv2d Layer. If stride is a list or tuple, it must contain two integers, (conv_stride_H, conv_stride_W). Otherwise, the conv_stride_H = conv_stride_W = conv_stride. Default: conv_stride = 1.

  • conv_padding (int|list|tuple) – The padding size of the conv2d Layer. If padding is a list or tuple, it must contain two integers, (conv_padding_H, conv_padding_W). Otherwise, the conv_padding_H = conv_padding_W = conv_padding. Default: conv_padding = 0.

  • conv_dilation (int|list|tuple) – The dilation size of the conv2d Layer. If dilation is a list or tuple, it must contain two integers, (conv_dilation_H, conv_dilation_W). Otherwise, the conv_dilation_H = conv_dilation_W = conv_dilation. Default: conv_dilation = 1.

  • conv_groups (int) – The groups number of the conv2d Layer. According to grouped convolution in Alex Krizhevsky’s Deep CNN paper: when group=2, 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 connected to the second half of the input channels. Default: groups=1.

  • param_attr (ParamAttr|None) – The parameter attribute for learnable parameters/weights of conv2d. If it is set to None or one attribute of ParamAttr, conv2d will create ParamAttr as param_attr. If the Initializer of the param_attr is not set, the parameter is initialized with Normal(0.0,std), and the std is (frac2.0filter_elem_num)0.5. Default: None.

  • bias_attr (ParamAttr|bool|None) – The parameter attribute for the bias of conv2d. If it is set to False, no bias will be added to the output units. 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 set, the bias is initialized zero. Default: None.

  • act (str) – Activation type for conv2d, if it is set to None, activation is not appended. Default: None.

  • use_cudnn (bool) – Use cudnn kernel or not, it is valid only when the cudnn library is installed. Default: True

Returns

4-D Tensor, the result of input after conv2d and pool2d, with the same data type as input

Return Type:

Variable

Examples

import paddle.fluid as fluid
import paddle
paddle.enable_static()
img = fluid.data(name='img', shape=[100, 1, 28, 28], dtype='float32')
conv_pool = fluid.nets.simple_img_conv_pool(input=img,
                                            filter_size=5,
                                            num_filters=20,
                                            pool_size=2,
                                            pool_stride=2,
                                            act="relu")