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

Function _preprocess_conv2d_input

tensorflow/python/keras/backend.py:4608–4628  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

4606
4607
4608def _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
4631def _preprocess_conv3d_input(x, data_format):

Callers 5

conv2dFunction · 0.85
conv2d_transposeFunction · 0.85
separable_conv2dFunction · 0.85
depthwise_conv2dFunction · 0.85
pool2dFunction · 0.85

Calls 2

_has_nchw_supportFunction · 0.85
transposeMethod · 0.80

Tested by

no test coverage detected