conv_utils
¶
Utilities used in convolutional layers.
Module Contents¶
Functions¶
|
Transforms a single int or iterable of ints into an int tuple. |
|
|
|
Converts a Numpy kernel matrix from Theano format to TensorFlow format. |
|
Determines output length of a convolution given input length. |
|
Determines input length of a convolution given output length. |
|
Determines output length of a transposed convolution given input length. |
-
conv_utils.
normalize_tuple
(value, n, name)¶ Transforms a single int or iterable of ints into an int tuple.
- # Arguments
- value: The value to validate and convert. Could be an int, or any iterable
of ints.
n: The size of the tuple to be returned. name: The name of the argument being validated, e.g. strides or
kernel_size. This is only used to format error messages.
- # Returns
A tuple of n integers.
- # Raises
ValueError: If something else than an int/long or iterable thereof was passed.
-
conv_utils.
normalize_padding
(value)¶
-
conv_utils.
convert_kernel
(kernel)¶ Converts a Numpy kernel matrix from Theano format to TensorFlow format.
Also works reciprocally, since the transformation is its own inverse.
- # Arguments
kernel: Numpy array (3D, 4D or 5D).
- # Returns
The converted kernel.
- # Raises
ValueError: in case of invalid kernel shape or invalid data_format.
-
conv_utils.
conv_output_length
(input_length, filter_size, padding, stride, dilation=1)¶ Determines output length of a convolution given input length.
- # Arguments
input_length: integer. filter_size: integer. padding: one of “same”, “valid”, “full”. stride: integer. dilation: dilation rate, integer.
- # Returns
The output length (integer).
-
conv_utils.
conv_input_length
(output_length, filter_size, padding, stride)¶ Determines input length of a convolution given output length.
- # Arguments
output_length: integer. filter_size: integer. padding: one of “same”, “valid”, “full”. stride: integer.
- # Returns
The input length (integer).
-
conv_utils.
deconv_length
(dim_size, stride_size, kernel_size, padding, output_padding, dilation=1)¶ Determines output length of a transposed convolution given input length.
- # Arguments
dim_size: Integer, the input length. stride_size: Integer, the stride along the dimension of dim_size. kernel_size: Integer, the kernel size along the dimension of
dim_size.
padding: One of “same”, “valid”, “full”. output_padding: Integer, amount of padding along the output dimension,
Can be set to None in which case the output length is inferred.
dilation: dilation rate, integer.
- # Returns
The output length (integer).