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

Function spatial_3d_padding

tensorflow/python/keras/backend.py:3032–3072  ·  view source on GitHub ↗

Pads 5D tensor with zeros along the depth, height, width dimensions. Pads these dimensions with respectively "padding[0]", "padding[1]" and "padding[2]" zeros left and right. For 'channels_last' data_format, the 2nd, 3rd and 4th dimension will be padded. For 'channels_first' data_format,

(x, padding=((1, 1), (1, 1), (1, 1)), data_format=None)

Source from the content-addressed store, hash-verified

3030
3031@keras_export('keras.backend.spatial_3d_padding')
3032def spatial_3d_padding(x, padding=((1, 1), (1, 1), (1, 1)), data_format=None):
3033 """Pads 5D tensor with zeros along the depth, height, width dimensions.
3034
3035 Pads these dimensions with respectively
3036 "padding[0]", "padding[1]" and "padding[2]" zeros left and right.
3037
3038 For 'channels_last' data_format,
3039 the 2nd, 3rd and 4th dimension will be padded.
3040 For 'channels_first' data_format,
3041 the 3rd, 4th and 5th dimension will be padded.
3042
3043 Arguments:
3044 x: Tensor or variable.
3045 padding: Tuple of 3 tuples, padding pattern.
3046 data_format: One of `channels_last` or `channels_first`.
3047
3048 Returns:
3049 A padded 5D tensor.
3050
3051 Raises:
3052 ValueError: if `data_format` is neither
3053 `channels_last` or `channels_first`.
3054
3055 """
3056 assert len(padding) == 3
3057 assert len(padding[0]) == 2
3058 assert len(padding[1]) == 2
3059 assert len(padding[2]) == 2
3060 if data_format is None:
3061 data_format = image_data_format()
3062 if data_format not in {'channels_first', 'channels_last'}:
3063 raise ValueError('Unknown data_format: ' + str(data_format))
3064
3065 if data_format == 'channels_first':
3066 pattern = [[0, 0], [0, 0], [padding[0][0], padding[0][1]],
3067 [padding[1][0], padding[1][1]], [padding[2][0], padding[2][1]]]
3068 else:
3069 pattern = [[0, 0], [padding[0][0], padding[0][1]],
3070 [padding[1][0], padding[1][1]], [padding[2][0],
3071 padding[2][1]], [0, 0]]
3072 return array_ops.pad(x, pattern)
3073
3074
3075@keras_export('keras.backend.stack')

Callers

nothing calls this directly

Calls 1

image_data_formatFunction · 0.85

Tested by

no test coverage detected