Transpose and cast the input before the conv2d. Arguments: x: input tensor. data_format: string, `"channels_last"` or `"channels_first"`. force_transpose: Boolean. If True, the input will always be transposed from NCHW to NHWC if `data_format` is `"channels_first"`.
(x, data_format, force_transpose=False)
| 4606 | |
| 4607 | |
| 4608 | def _preprocess_conv2d_input(x, data_format, force_transpose=False): |
| 4609 | """Transpose and cast the input before the conv2d. |
| 4610 | |
| 4611 | Arguments: |
| 4612 | x: input tensor. |
| 4613 | data_format: string, `"channels_last"` or `"channels_first"`. |
| 4614 | force_transpose: Boolean. If True, the input will always be transposed |
| 4615 | from NCHW to NHWC if `data_format` is `"channels_first"`. |
| 4616 | If False, the transposition only occurs on CPU (GPU ops are |
| 4617 | assumed to support NCHW). |
| 4618 | |
| 4619 | Returns: |
| 4620 | A tensor. |
| 4621 | """ |
| 4622 | tf_data_format = 'NHWC' |
| 4623 | if data_format == 'channels_first': |
| 4624 | if not _has_nchw_support() or force_transpose: |
| 4625 | x = array_ops.transpose(x, (0, 2, 3, 1)) # NCHW -> NHWC |
| 4626 | else: |
| 4627 | tf_data_format = 'NCHW' |
| 4628 | return x, tf_data_format |
| 4629 | |
| 4630 | |
| 4631 | def _preprocess_conv3d_input(x, data_format): |
no test coverage detected