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

Function pool

tensorflow/python/ops/nn_ops.py:1182–1352  ·  view source on GitHub ↗

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,
    padding,
    dilation_rate=None,
    strides=None,
    name=None,
    data_format=None,
    dilations=None)

Source from the content-addressed store, hash-verified

1180
1181@tf_export(v1=["nn.pool"])
1182def pool(
1183 input, # pylint: disable=redefined-builtin
1184 window_shape,
1185 pooling_type,
1186 padding,
1187 dilation_rate=None,
1188 strides=None,
1189 name=None,
1190 data_format=None,
1191 dilations=None):
1192 """Performs an N-D pooling operation.
1193
1194 In the case that `data_format` does not start with "NC", computes for
1195 0 <= b < batch_size,
1196 0 <= x[i] < output_spatial_shape[i],
1197 0 <= c < num_channels:
1198
1199 ```
1200 output[b, x[0], ..., x[N-1], c] =
1201 REDUCE_{z[0], ..., z[N-1]}
1202 input[b,
1203 x[0] * strides[0] - pad_before[0] + dilation_rate[0]*z[0],
1204 ...
1205 x[N-1]*strides[N-1] - pad_before[N-1] + dilation_rate[N-1]*z[N-1],
1206 c],
1207 ```
1208
1209 where the reduction function REDUCE depends on the value of `pooling_type`,
1210 and pad_before is defined based on the value of `padding` as described in
1211 the "returns" section of `tf.nn.convolution` for details.
1212 The reduction never includes out-of-bounds positions.
1213
1214 In the case that `data_format` starts with `"NC"`, the `input` and output are
1215 simply transposed as follows:
1216
1217 ```
1218 pool(input, data_format, **kwargs) =
1219 tf.transpose(pool(tf.transpose(input, [0] + range(2,N+2) + [1]),
1220 **kwargs),
1221 [0, N+1] + range(1, N+1))
1222 ```
1223
1224 Args:
1225 input: Tensor of rank N+2, of shape
1226 `[batch_size] + input_spatial_shape + [num_channels]` if data_format does
1227 not start with "NC" (default), or
1228 `[batch_size, num_channels] + input_spatial_shape` if data_format starts
1229 with "NC". Pooling happens over the spatial dimensions only.
1230 window_shape: Sequence of N ints >= 1.
1231 pooling_type: Specifies pooling operation, must be "AVG" or "MAX".
1232 padding: The padding algorithm, must be "SAME" or "VALID".
1233 See the "returns" section of `tf.nn.convolution` for details.
1234 dilation_rate: Optional. Dilation rate. List of N ints >= 1.
1235 Defaults to [1]*N. If any value of dilation_rate is > 1, then all values
1236 of strides must be 1.
1237 strides: Optional. Sequence of N ints >= 1. Defaults to [1]*N.
1238 If any value of strides is > 1, then all values of dilation_rate must be
1239 1.

Callers 1

pool_v2Function · 0.70

Calls 7

with_space_to_batchFunction · 0.85
with_rankMethod · 0.80
rangeFunction · 0.70
name_scopeMethod · 0.45
get_shapeMethod · 0.45

Tested by

no test coverage detected