tf.nn.fractional_max_pool
Stay organized with collections
Save and categorize content based on your preferences.
Performs fractional max pooling on the input.
tf.nn.fractional_max_pool(
value,
pooling_ratio,
pseudo_random=False,
overlapping=False,
seed=0,
name=None
)
Fractional max pooling is slightly different than regular max pooling. In
regular max pooling, you downsize an input set by taking the maximum value of
smaller N x N subsections of the set (often 2x2), and try to reduce the set by
a factor of N, where N is an integer. Fractional max pooling, as you might
expect from the word "fractional", means that the overall reduction ratio N
does not have to be an integer.
The sizes of the pooling regions are generated randomly but are fairly
uniform. For example, let's look at the height dimension, and the constraints
on the list of rows that will be pool boundaries.
First we define the following:
- input_row_length : the number of rows from the input set
- output_row_length : which will be smaller than the input
- alpha = input_row_length / output_row_length : our reduction ratio
- K = floor(alpha)
- row_pooling_sequence : this is the result list of pool boundary rows
Then, row_pooling_sequence should satisfy:
- a[0] = 0 : the first value of the sequence is 0
- a[end] = input_row_length : the last value of the sequence is the size
- K <= (a[i+1] - a[i]) <= K+1 : all intervals are K or K+1 size
- length(row_pooling_sequence) = output_row_length+1
Args |
value
|
A Tensor . 4-D with shape [batch, height, width, channels] .
|
pooling_ratio
|
An int or list of ints that has length 1 , 2 or 4 .
Pooling ratio for each dimension of value , currently only supports row
and col dimension and should be >= 1.0. For example, a valid pooling ratio
looks like [1.0, 1.44, 1.73, 1.0]. The first and last elements must be 1.0
because we don't allow pooling on batch and channels dimensions. 1.44 and
1.73 are pooling ratio on height and width dimensions respectively.
|
pseudo_random
|
An optional bool . Defaults to False . When set to True ,
generates the pooling sequence in a pseudorandom fashion, otherwise, in a
random fashion. Check paper (Graham, 2015) for difference between
pseudorandom and random.
|
overlapping
|
An optional bool . Defaults to False . When set to True ,
it means when pooling, the values at the boundary of adjacent pooling
cells are used by both cells. For example:
index 0 1 2 3 4
value 20 5 16 3 7
If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used
twice. The result would be [20, 16] for fractional max pooling.
|
seed
|
An optional int . Defaults to 0 . If set to be non-zero, the
random number generator is seeded by the given seed. Otherwise it is
seeded by a random seed.
|
name
|
A name for the operation (optional).
|
A tuple of Tensor
objects (output
, row_pooling_sequence
,
col_pooling_sequence
).
output: Output Tensor
after fractional max pooling. Has the same type as
value
.
row_pooling_sequence: A Tensor
of type int64
.
col_pooling_sequence: A Tensor
of type int64
.
Raises |
ValueError
|
If no seed is specified and op determinism is enabled.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.nn.fractional_max_pool\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/nn_ops.py#L6141-L6252) |\n\nPerforms fractional max pooling on the input. \n\n tf.nn.fractional_max_pool(\n value,\n pooling_ratio,\n pseudo_random=False,\n overlapping=False,\n seed=0,\n name=None\n )\n\nFractional max pooling is slightly different than regular max pooling. In\nregular max pooling, you downsize an input set by taking the maximum value of\nsmaller N x N subsections of the set (often 2x2), and try to reduce the set by\na factor of N, where N is an integer. Fractional max pooling, as you might\nexpect from the word \"fractional\", means that the overall reduction ratio N\ndoes not have to be an integer.\n\nThe sizes of the pooling regions are generated randomly but are fairly\nuniform. For example, let's look at the height dimension, and the constraints\non the list of rows that will be pool boundaries.\n\nFirst we define the following:\n\n1. input_row_length : the number of rows from the input set\n2. output_row_length : which will be smaller than the input\n3. alpha = input_row_length / output_row_length : our reduction ratio\n4. K = floor(alpha)\n5. row_pooling_sequence : this is the result list of pool boundary rows\n\nThen, row_pooling_sequence should satisfy:\n\n1. a\\[0\\] = 0 : the first value of the sequence is 0\n2. a\\[end\\] = input_row_length : the last value of the sequence is the size\n3. K \\\u003c= (a\\[i+1\\] - a\\[i\\]) \\\u003c= K+1 : all intervals are K or K+1 size\n4. length(row_pooling_sequence) = output_row_length+1\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `value` | A `Tensor`. 4-D with shape `[batch, height, width, channels]`. |\n| `pooling_ratio` | An int or list of `ints` that has length `1`, `2` or `4`. Pooling ratio for each dimension of `value`, currently only supports row and col dimension and should be \\\u003e= 1.0. For example, a valid pooling ratio looks like \\[1.0, 1.44, 1.73, 1.0\\]. The first and last elements must be 1.0 because we don't allow pooling on batch and channels dimensions. 1.44 and 1.73 are pooling ratio on height and width dimensions respectively. |\n| `pseudo_random` | An optional `bool`. Defaults to `False`. When set to `True`, generates the pooling sequence in a pseudorandom fashion, otherwise, in a random fashion. Check paper (Graham, 2015) for difference between pseudorandom and random. |\n| `overlapping` | An optional `bool`. Defaults to `False`. When set to `True`, it means when pooling, the values at the boundary of adjacent pooling cells are used by both cells. For example: `index 0 1 2 3 4` `value 20 5 16 3 7` If the pooling sequence is \\[0, 2, 4\\], then 16, at index 2 will be used twice. The result would be \\[20, 16\\] for fractional max pooling. |\n| `seed` | An optional `int`. Defaults to `0`. If set to be non-zero, the random number generator is seeded by the given seed. Otherwise it is seeded by a random seed. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n\n\u003cbr /\u003e\n\nA tuple of `Tensor` objects (`output`, `row_pooling_sequence`,\n`col_pooling_sequence`).\noutput: Output `Tensor` after fractional max pooling. Has the same type as\n`value`.\nrow_pooling_sequence: A `Tensor` of type `int64`.\ncol_pooling_sequence: A `Tensor` of type `int64`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------------------------------|\n| `ValueError` | If no seed is specified and op determinism is enabled. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| References ---------- ||\n|---|---|\n| Fractional Max-Pooling: [Graham, 2015](https://arxiv.org/abs/1412.6071) ([pdf](https://arxiv.org/pdf/1412.6071.pdf)) ||\n\n\u003cbr /\u003e"]]