Performs an N-D pooling operation. In the case that `data_format` does not start with "NC", computes for 0 <= b < batch_size, 0 <= x[i] < output_spatial_shape[i], 0 <= c < num_channels: ``` output[b, x[0], ..., x[N-1], c] = REDUCE_{z[0], ..., z[N-1]} input[b
(
input, # pylint: disable=redefined-builtin
window_shape,
pooling_type,
strides=None,
padding="VALID",
data_format=None,
dilations=None,
name=None)
| 1354 | |
| 1355 | @tf_export("nn.pool", v1=[]) |
| 1356 | def pool_v2( |
| 1357 | input, # pylint: disable=redefined-builtin |
| 1358 | window_shape, |
| 1359 | pooling_type, |
| 1360 | strides=None, |
| 1361 | padding="VALID", |
| 1362 | data_format=None, |
| 1363 | dilations=None, |
| 1364 | name=None): |
| 1365 | # pylint: disable=line-too-long |
| 1366 | """Performs an N-D pooling operation. |
| 1367 | |
| 1368 | In the case that `data_format` does not start with "NC", computes for |
| 1369 | 0 <= b < batch_size, |
| 1370 | 0 <= x[i] < output_spatial_shape[i], |
| 1371 | 0 <= c < num_channels: |
| 1372 | |
| 1373 | ``` |
| 1374 | output[b, x[0], ..., x[N-1], c] = |
| 1375 | REDUCE_{z[0], ..., z[N-1]} |
| 1376 | input[b, |
| 1377 | x[0] * strides[0] - pad_before[0] + dilation_rate[0]*z[0], |
| 1378 | ... |
| 1379 | x[N-1]*strides[N-1] - pad_before[N-1] + dilation_rate[N-1]*z[N-1], |
| 1380 | c], |
| 1381 | ``` |
| 1382 | |
| 1383 | where the reduction function REDUCE depends on the value of `pooling_type`, |
| 1384 | and pad_before is defined based on the value of `padding` as described in |
| 1385 | the "returns" section of `tf.nn.convolution` for details. |
| 1386 | The reduction never includes out-of-bounds positions. |
| 1387 | |
| 1388 | In the case that `data_format` starts with `"NC"`, the `input` and output are |
| 1389 | simply transposed as follows: |
| 1390 | |
| 1391 | ``` |
| 1392 | pool(input, data_format, **kwargs) = |
| 1393 | tf.transpose(pool(tf.transpose(input, [0] + range(2,N+2) + [1]), |
| 1394 | **kwargs), |
| 1395 | [0, N+1] + range(1, N+1)) |
| 1396 | ``` |
| 1397 | |
| 1398 | Args: |
| 1399 | input: Tensor of rank N+2, of shape `[batch_size] + input_spatial_shape + |
| 1400 | [num_channels]` if data_format does not start with "NC" (default), or |
| 1401 | `[batch_size, num_channels] + input_spatial_shape` if data_format starts |
| 1402 | with "NC". Pooling happens over the spatial dimensions only. |
| 1403 | window_shape: Sequence of N ints >= 1. |
| 1404 | pooling_type: Specifies pooling operation, must be "AVG" or "MAX". |
| 1405 | strides: Optional. Sequence of N ints >= 1. Defaults to [1]*N. If any value of |
| 1406 | strides is > 1, then all values of dilation_rate must be 1. |
| 1407 | padding: The padding algorithm, must be "SAME" or "VALID". Defaults to "SAME". |
| 1408 | See the "returns" section of `tf.nn.convolution` for details. |
| 1409 | data_format: A string or None. Specifies whether the channel dimension of |
| 1410 | the `input` and output is the last dimension (default, or if `data_format` |
| 1411 | does not start with "NC"), or the second dimension (if `data_format` |
| 1412 | starts with "NC"). For N=1, the valid values are "NWC" (default) and |
| 1413 | "NCW". For N=2, the valid values are "NHWC" (default) and "NCHW". For |