MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / conv2d_transpose

Function conv2d_transpose

tensorflow/python/keras/backend.py:4765–4834  ·  view source on GitHub ↗

2D deconvolution (i.e. transposed convolution). Arguments: x: Tensor or variable. kernel: kernel tensor. output_shape: 1D int tensor for the output shape. strides: strides tuple. padding: string, `"same"` or `"valid"`. data_format: string, `"channels_last"`

(x,
                     kernel,
                     output_shape,
                     strides=(1, 1),
                     padding='valid',
                     data_format=None,
                     dilation_rate=(1, 1))

Source from the content-addressed store, hash-verified

4763
4764@keras_export('keras.backend.conv2d_transpose')
4765def conv2d_transpose(x,
4766 kernel,
4767 output_shape,
4768 strides=(1, 1),
4769 padding='valid',
4770 data_format=None,
4771 dilation_rate=(1, 1)):
4772 """2D deconvolution (i.e.
4773
4774 transposed convolution).
4775
4776 Arguments:
4777 x: Tensor or variable.
4778 kernel: kernel tensor.
4779 output_shape: 1D int tensor for the output shape.
4780 strides: strides tuple.
4781 padding: string, `"same"` or `"valid"`.
4782 data_format: string, `"channels_last"` or `"channels_first"`.
4783 dilation_rate: Tuple of 2 integers.
4784
4785 Returns:
4786 A tensor, result of transposed 2D convolution.
4787
4788 Raises:
4789 ValueError: if `data_format` is neither `channels_last` or
4790 `channels_first`.
4791 """
4792 if data_format is None:
4793 data_format = image_data_format()
4794 if data_format not in {'channels_first', 'channels_last'}:
4795 raise ValueError('Unknown data_format: ' + str(data_format))
4796
4797 # `atrous_conv2d_transpose` only supports NHWC format, even on GPU.
4798 if data_format == 'channels_first' and dilation_rate != (1, 1):
4799 force_transpose = True
4800 else:
4801 force_transpose = False
4802
4803 x, tf_data_format = _preprocess_conv2d_input(x, data_format, force_transpose)
4804
4805 if data_format == 'channels_first' and tf_data_format == 'NHWC':
4806 output_shape = (output_shape[0], output_shape[2], output_shape[3],
4807 output_shape[1])
4808 if output_shape[0] is None:
4809 output_shape = (shape(x)[0],) + tuple(output_shape[1:])
4810
4811 if isinstance(output_shape, (tuple, list)):
4812 output_shape = array_ops.stack(list(output_shape))
4813
4814 padding = _preprocess_padding(padding)
4815 if tf_data_format == 'NHWC':
4816 strides = (1,) + strides + (1,)
4817 else:
4818 strides = (1, 1) + strides
4819
4820 if dilation_rate == (1, 1):
4821 x = nn.conv2d_transpose(x, kernel, output_shape, strides,
4822 padding=padding,

Callers

nothing calls this directly

Calls 7

image_data_formatFunction · 0.85
_preprocess_conv2d_inputFunction · 0.85
tupleFunction · 0.85
_preprocess_paddingFunction · 0.85
transposeMethod · 0.80
shapeFunction · 0.70
stackMethod · 0.45

Tested by

no test coverage detected