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

Function pool

tensorflow/contrib/layers/python/layers/layers.py:2514–2579  ·  view source on GitHub ↗

Adds a pooling op. Args: inputs: Tensor of rank N+2, of shape `[batch_size] + input_spatial_shape + [num_channels]` if data_format does not start with "NC" (default), or `[batch_size, num_channels] + input_spatial_shape` if data_format starts with "NC". Pooling happens ove

(inputs,
         kernel_size,
         pooling_type,
         padding='VALID',
         data_format=None,
         dilation_rate=1,
         stride=1,
         outputs_collections=None,
         scope=None)

Source from the content-addressed store, hash-verified

2512
2513@add_arg_scope
2514def pool(inputs,
2515 kernel_size,
2516 pooling_type,
2517 padding='VALID',
2518 data_format=None,
2519 dilation_rate=1,
2520 stride=1,
2521 outputs_collections=None,
2522 scope=None):
2523 # pylint: disable=line-too-long
2524 """Adds a pooling op.
2525
2526
2527 Args:
2528 inputs: Tensor of rank N+2, of shape `[batch_size] + input_spatial_shape +
2529 [num_channels]` if data_format does not start with "NC" (default), or
2530 `[batch_size, num_channels] + input_spatial_shape` if data_format starts
2531 with "NC". Pooling happens over the spatial dimensions only.
2532 kernel_size: Sequence of N ints >= 1. Can also be a single integer to
2533 specify the same value for all spatial dimensions.
2534 pooling_type: Specifies pooling operation, must be "AVG" or "MAX".
2535 padding: The padding algorithm, must be "SAME" or "VALID".
2536 data_format: A string or None. Specifies whether the channel dimension of
2537 the `input` and output is the last dimension (default, or if `data_format`
2538 does not start with "NC"), or the second dimension (if `data_format`
2539 starts with "NC"). For N=1, the valid values are "NWC" (default) and
2540 "NCW". For N=2, the valid values are "NHWC" (default) and "NCHW". For
2541 N=3, the valid values are "NDHWC" (default) and "NCDHW".
2542 dilation_rate: Optional. Dilation rate. Sequence of N ints >= 1. Defaults
2543 to [1]*N. Can also be a single integer to specify the same value for all
2544 spatial dimensions. If any value of dilation_rate is > 1, then all values
2545 of stride must be 1.
2546 stride: Optional. Sequence of N ints >= 1. Defaults to [1]*N. Can also be
2547 a single integer to specify the same value for all spatial dimensions. If
2548 any value of stride is > 1, then all values of dilation_rate must be 1.
2549 outputs_collections: The collections to which the outputs are added.
2550 scope: Optional scope for name_scope.
2551
2552 Returns:
2553 A `Tensor` representing the results of the pooling operation.
2554
2555 Raises:
2556 ValueError: If arguments are invalid.
2557
2558 """
2559 # pylint: enable=line-too-long
2560 with ops.name_scope(scope, '%s_pool' % (pooling_type.lower()),
2561 [inputs]) as sc:
2562 inputs = ops.convert_to_tensor(inputs)
2563 input_rank = inputs.get_shape().ndims
2564 if input_rank is None:
2565 raise ValueError('Rank of inputs must be known')
2566 if input_rank < 3:
2567 raise ValueError('Rank of inputs must be >= 3')
2568 num_spatial_dims = input_rank - 2
2569 output = nn.pool(
2570 input=inputs,
2571 window_shape=utils.n_positive_integers(num_spatial_dims, kernel_size),

Callers 1

modelMethod · 0.50

Calls 2

name_scopeMethod · 0.45
get_shapeMethod · 0.45

Tested by 1

modelMethod · 0.40