Transpose and cast the input before the conv1d. Arguments: x: input tensor. data_format: string, `"channels_last"` or `"channels_first"`. Returns: A tensor.
(x, data_format)
| 4587 | |
| 4588 | |
| 4589 | def _preprocess_conv1d_input(x, data_format): |
| 4590 | """Transpose and cast the input before the conv1d. |
| 4591 | |
| 4592 | Arguments: |
| 4593 | x: input tensor. |
| 4594 | data_format: string, `"channels_last"` or `"channels_first"`. |
| 4595 | |
| 4596 | Returns: |
| 4597 | A tensor. |
| 4598 | """ |
| 4599 | tf_data_format = 'NWC' # to pass TF Conv2dNative operations |
| 4600 | if data_format == 'channels_first': |
| 4601 | if not _has_nchw_support(): |
| 4602 | x = array_ops.transpose(x, (0, 2, 1)) # NCW -> NWC |
| 4603 | else: |
| 4604 | tf_data_format = 'NCW' |
| 4605 | return x, tf_data_format |
| 4606 | |
| 4607 | |
| 4608 | def _preprocess_conv2d_input(x, data_format, force_transpose=False): |
no test coverage detected