View source on GitHub
|
Adaptive average pooling operation.
tf.keras.ops.adaptive_average_pool(
inputs, output_size, data_format=None
)
Applies an adaptive average pooling operation that automatically
computes the kernel size and stride to pool the input to the
specified output_size. This operation is useful when you want a
fixed output size regardless of input size, commonly used in models
like ResNet for global feature extraction.
Returns | |
|---|---|
| A tensor of rank 4 representing the adaptive average pooled result. |
Example:
x = np.random.rand(2, 64, 64, 3)y = keras.ops.adaptive_average_pool(x, output_size=(32, 32))y.shape(2, 32, 32, 3)
# Works with any input sizex = np.random.rand(2, 100, 80, 3)y = keras.ops.adaptive_average_pool(x, output_size=7)y.shape(2, 7, 7, 3)
View source on GitHub