3D Pooling. Arguments: x: Tensor or variable. pool_size: tuple of 3 integers. strides: tuple of 3 integers. padding: string, `"same"` or `"valid"`. data_format: string, `"channels_last"` or `"channels_first"`. pool_mode: string, `"max"` or `"avg"`. Returns:
(x,
pool_size,
strides=(1, 1, 1),
padding='valid',
data_format=None,
pool_mode='max')
| 5169 | |
| 5170 | @keras_export('keras.backend.pool3d') |
| 5171 | def pool3d(x, |
| 5172 | pool_size, |
| 5173 | strides=(1, 1, 1), |
| 5174 | padding='valid', |
| 5175 | data_format=None, |
| 5176 | pool_mode='max'): |
| 5177 | """3D Pooling. |
| 5178 | |
| 5179 | Arguments: |
| 5180 | x: Tensor or variable. |
| 5181 | pool_size: tuple of 3 integers. |
| 5182 | strides: tuple of 3 integers. |
| 5183 | padding: string, `"same"` or `"valid"`. |
| 5184 | data_format: string, `"channels_last"` or `"channels_first"`. |
| 5185 | pool_mode: string, `"max"` or `"avg"`. |
| 5186 | |
| 5187 | Returns: |
| 5188 | A tensor, result of 3D pooling. |
| 5189 | |
| 5190 | Raises: |
| 5191 | ValueError: if `data_format` is neither `"channels_last"` or |
| 5192 | `"channels_first"`. |
| 5193 | ValueError: if `pool_mode` is neither `"max"` or `"avg"`. |
| 5194 | """ |
| 5195 | if data_format is None: |
| 5196 | data_format = image_data_format() |
| 5197 | if data_format not in {'channels_first', 'channels_last'}: |
| 5198 | raise ValueError('Unknown data_format: ' + str(data_format)) |
| 5199 | |
| 5200 | x, tf_data_format = _preprocess_conv3d_input(x, data_format) |
| 5201 | padding = _preprocess_padding(padding) |
| 5202 | if tf_data_format == 'NDHWC': |
| 5203 | strides = (1,) + strides + (1,) |
| 5204 | pool_size = (1,) + pool_size + (1,) |
| 5205 | else: |
| 5206 | strides = (1, 1) + strides |
| 5207 | pool_size = (1, 1) + pool_size |
| 5208 | |
| 5209 | if pool_mode == 'max': |
| 5210 | x = nn.max_pool3d( |
| 5211 | x, pool_size, strides, padding=padding, data_format=tf_data_format) |
| 5212 | elif pool_mode == 'avg': |
| 5213 | x = nn.avg_pool3d( |
| 5214 | x, pool_size, strides, padding=padding, data_format=tf_data_format) |
| 5215 | else: |
| 5216 | raise ValueError('Invalid pooling mode: ' + str(pool_mode)) |
| 5217 | |
| 5218 | if data_format == 'channels_first' and tf_data_format == 'NDHWC': |
| 5219 | x = array_ops.transpose(x, (0, 4, 1, 2, 3)) |
| 5220 | return x |
| 5221 | |
| 5222 | |
| 5223 | def local_conv(inputs, |
nothing calls this directly
no test coverage detected