3D deconvolution (i.e. transposed convolution). Arguments: x: input tensor. 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"` or `"chann
(x,
kernel,
output_shape,
strides=(1, 1, 1),
padding='valid',
data_format=None)
| 5050 | |
| 5051 | |
| 5052 | def conv3d_transpose(x, |
| 5053 | kernel, |
| 5054 | output_shape, |
| 5055 | strides=(1, 1, 1), |
| 5056 | padding='valid', |
| 5057 | data_format=None): |
| 5058 | """3D deconvolution (i.e. |
| 5059 | |
| 5060 | transposed convolution). |
| 5061 | |
| 5062 | Arguments: |
| 5063 | x: input tensor. |
| 5064 | kernel: kernel tensor. |
| 5065 | output_shape: 1D int tensor for the output shape. |
| 5066 | strides: strides tuple. |
| 5067 | padding: string, "same" or "valid". |
| 5068 | data_format: string, `"channels_last"` or `"channels_first"`. |
| 5069 | |
| 5070 | Returns: |
| 5071 | A tensor, result of transposed 3D convolution. |
| 5072 | |
| 5073 | Raises: |
| 5074 | ValueError: if `data_format` is neither `channels_last` or |
| 5075 | `channels_first`. |
| 5076 | """ |
| 5077 | if data_format is None: |
| 5078 | data_format = image_data_format() |
| 5079 | if data_format not in {'channels_first', 'channels_last'}: |
| 5080 | raise ValueError('Unknown data_format: ' + str(data_format)) |
| 5081 | if isinstance(output_shape, (tuple, list)): |
| 5082 | output_shape = array_ops.stack(output_shape) |
| 5083 | |
| 5084 | x, tf_data_format = _preprocess_conv3d_input(x, data_format) |
| 5085 | |
| 5086 | if data_format == 'channels_first' and tf_data_format == 'NDHWC': |
| 5087 | output_shape = (output_shape[0], output_shape[2], output_shape[3], |
| 5088 | output_shape[4], output_shape[1]) |
| 5089 | if output_shape[0] is None: |
| 5090 | output_shape = (array_ops.shape(x)[0],) + tuple(output_shape[1:]) |
| 5091 | output_shape = array_ops.stack(list(output_shape)) |
| 5092 | |
| 5093 | padding = _preprocess_padding(padding) |
| 5094 | if tf_data_format == 'NDHWC': |
| 5095 | strides = (1,) + strides + (1,) |
| 5096 | else: |
| 5097 | strides = (1, 1) + strides |
| 5098 | |
| 5099 | x = nn.conv3d_transpose( |
| 5100 | x, |
| 5101 | kernel, |
| 5102 | output_shape, |
| 5103 | strides, |
| 5104 | padding=padding, |
| 5105 | data_format=tf_data_format) |
| 5106 | if data_format == 'channels_first' and tf_data_format == 'NDHWC': |
| 5107 | x = array_ops.transpose(x, (0, 4, 1, 2, 3)) |
| 5108 | return x |
| 5109 |
nothing calls this directly
no test coverage detected