|View source on GitHub|
Adds an N-D convolution followed by an optional batch_norm layer.
tf.contrib.layers.convolution( inputs, num_outputs, kernel_size, stride=1, padding='SAME', data_format=None, rate=1, activation_fn=tf.nn.relu, normalizer_fn=None, normalizer_params=None, weights_initializer=initializers.xavier_initializer(), weights_regularizer=None, biases_initializer=tf.zeros_initializer(), biases_regularizer=None, reuse=None, variables_collections=None, outputs_collections=None, trainable=True, scope=None, conv_dims=None )
It is required that 1 <= N <= 3.
convolution creates a variable called
weights, representing the
convolutional kernel, that is convolved (actually cross-correlated) with the
inputs to produce a
Tensor of activations. If a
provided (such as
batch_norm), it is then applied. Otherwise, if
normalizer_fn is None and a
biases_initializer is provided then a
variable would be created and added the activations. Finally, if
activation_fn is not
None, it is applied to the activations as well.
Performs atrous convolution with input stride/dilation rate equal to
if a value > 1 for any dimension of
rate is specified. In this case
stride values != 1 are not supported.
inputs: A Tensor of rank N+2 of shape
[batch_size] + input_spatial_shape + [in_channels]if data_format does not start with "NC" (default), or
[batch_size, in_channels] + input_spatial_shapeif data_format starts with "NC".
num_outputs: Integer, the number of output filters.
kernel_size: A sequence of N positive integers specifying the spatial dimensions of the filters. Can be a single integer to specify the same value for all spatial dimensions.
stride: A sequence of N positive integers specifying the stride at which to compute output. Can be a single integer to specify the same value for all spatial dimensions. Specifying any
stridevalue != 1 is incompatible with specifying any
ratevalue != 1.
padding: One of
data_format: A string or None. Specifies whether the channel dimension of the
inputand output is the last dimension (default, or if
data_formatdoes not start with "NC"), or the second dimension (if
data_formatstarts with "NC"). For N=1, the valid values are "NWC" (default) and "NCW". For N=2, the valid values are "NHWC" (default) and "NCHW". For N=3, the valid values are "NDHWC" (default) and "NCDHW".
rate: A sequence of N positive integers specifying the dilation rate to use for atrous convolution. Can be a single integer to specify the same value for all spatial dimensions. Specifying any
ratevalue != 1 is incompatible with specifying any
stridevalue != 1.
activation_fn: Activation function. The default value is a ReLU function. Explicitly set it to None to skip it and maintain a linear activation.
normalizer_fn: Normalization function to use instead of
normalizer_fnis provided then
biases_regularizerare ignored and
biasesare not created nor added. default set to None for no normalizer function
normalizer_params: Normalization function parameters.
weights_initializer: An initializer for the weights.
weights_regularizer: Optional regularizer for the weights.
biases_initializer: An initializer for the biases. If None skip biases.
biases_regularizer: Optional regularizer for the biases.
reuse: Whether or not the layer and its variables should be reused. To be able to reuse the layer scope must be given.
variables_collections: Optional list of collections for all the variables or a dictionary containing a different list of collection per variable.
outputs_collections: Collection to add the outputs.
Truealso add variables to the graph collection
scope: Optional scope for
conv_dims: Optional convolution dimensionality, when set it would use the corresponding convolution (e.g. 2 for Conv 2D, 3 for Conv 3D, ..). When leaved to None it would select the convolution dimensionality based on the input rank (i.e. Conv ND, with N = input_rank - 2).
A tensor representing the output of the operation.
ValueError: Both 'rate' and
strideare not uniformly 1.