var_conv_2d¶
- paddle.fluid.contrib.layers.nn. var_conv_2d ( input, row, col, input_channel, output_channel, filter_size, stride=1, param_attr=None, act=None, dtype='float32', name=None ) [source]
-
The var_conv_2d layer calculates the output base on the
input
with variable length, row, col, input channel, filter size and strides. Bothinput
,row
, andcol
are 1-level LodTensor. The convolution operation is same as conv2d layer with padding. Besides, input.dims[1] should be 1.If input_channel is 2 and given row lodTensor and col lodTensor as follows: row.lod = [[5, 4]] col.lod = [[6, 7]] input is a lodTensor: input.lod = [[60, 56]] # where 60 = input_channel * 5 * 6 input.dims = [116, 1] # where 116 = 60 + 56 If set output_channel is 3, filter_size is [3, 3], stride is [1, 1]: # where 90 = output_channel * [(5-1)/stride + 1] * [(6-1)/stride + 1] output.lod = [[90, 84]] output.dims = [174, 1] # where 174 = 90 + 84
- Args:
-
input (Variable): The input should be 1-level LodTensor with dims[1] equals 1. row (Variable): The row should be 1-level LodTensor to provide height information. col (Variable): The col should be 1-level LodTensor to provide width information. input_channel (int): The number of input channel. output_channel (int): The number of output channel. filter_size (int|tuple|None): The filter size. If filter_size is a tuple,
it must contain two integers, (filter_size_H, filter_size_W). Otherwise, the filter will be a square.
- stride (int|tuple): The stride size. If stride is a tuple, it must
-
contain two integers, (stride_H, stride_W). Otherwise, the stride_H = stride_W = stride. Default: stride = 1.
- param_attr (ParamAttr|None): The parameter attribute for learnable parameters/weights
-
of var_conv2d. If it is set to None or one attribute of ParamAttr, var_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 :math:`(\frac{2.0 }{filter_elem_num})^{
- 0.5}`. Default: None.
-
- act (str): Activation type, if it is set to None, activation is not appended.
-
Default: None
dtype (‘float32’): The data type of parameter and output. name (str|None): A name for this layer(optional). If set None, the layer
will be named automatically. Default: None
- Returns:
-
Variable: Output variable with LoD specified by this layer.
- Examples:
-
import numpy as np from paddle.fluid import layers from paddle.fluid import contrib x_lod_tensor = layers.data(name='x', shape=[1], lod_level=1) row_lod_tensor = layers.data(name='row', shape=[6], lod_level=1) col_lod_tensor = layers.data(name='col', shape=[6], lod_level=1) out = contrib.var_conv_2d(input=x_lod_tensor, row=row_lod_tensor, col=col_lod_tensor, input_channel=3, output_channel=5, filter_size=[3, 3], stride=1)