<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/layers/pooling/adaptive_max_pooling3d.py#L9-L63) |

Adaptive max pooling operation for 3D volumetric data.

Inherits From: [`Layer`](https://www.tensorflow.org/api_docs/python/tf/keras/Layer), [`Operation`](https://www.tensorflow.org/api_docs/python/tf/keras/Operation)

    tf.keras.layers.AdaptiveMaxPooling3D(
        output_size, data_format=None, **kwargs
    )

This layer applies an adaptive max pooling operation, which pools the
input such that the output has a target spatial size specified by
`output_size`, regardless of the input spatial size. The kernel size
and stride are automatically computed to achieve the target output size.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `output_size` | Integer or tuple of 3 integers specifying the target output size. If an integer, the same value is used for depth, height, and width. |
| `data_format` | string, either `"channels_last"` or `"channels_first"`. `"channels_last"` corresponds to inputs with shape `(batch, depth, height, width, channels)`. `"channels_first"` corresponds to inputs with shape `(batch, channels, depth, height, width)`. Defaults to the value found in your Keras config file at `~/.keras/keras.json`. If never set, `"channels_last"` is used. |

<br />

<br />

<br />

| ## Input shape ||
|---|---|
| <br /> - If `data_format="channels_last"`: 5D tensor `(batch_size, depth, height, width, channels)` - If `data_format="channels_first"`: 5D tensor `(batch_size, channels, depth, height, width)` ||

<br />

<br />

<br />

| ## Output shape ||
|---|---|
| <br /> - If `data_format="channels_last"`: `(batch_size, output_depth, output_height, output_width, channels)` - If `data_format="channels_first"`: `(batch_size, channels, output_depth, output_height, output_width)` ||

<br />

<br />

<br />

<br />

| ## Examples ||
|---|---|
| <br /> >>> import numpy as np >>> input_vol = np.random.rand(1, 32, 32, 32, 3) >>> layer = AdaptiveMaxPooling3D(output_size=16) >>> output_vol = layer(input_vol) >>> output_vol.shape (1, 16, 16, 16, 3) <br /> ||

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `input` | Retrieves the input tensor(s) of a symbolic operation. <br /> Only returns the tensor(s) corresponding to the *first time* the operation was called. |
| `output` | Retrieves the output tensor(s) of a layer. <br /> Only returns the tensor(s) corresponding to the *first time* the operation was called. |

<br />

## Methods

### `from_config`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/operation.py#L322-L362)

    @classmethod
    from_config(
        config
    )

Creates an operation from its config.

This method is the reverse of `get_config`, capable of instantiating the
same operation from the config dictionary.

> [!NOTE]
> **Note:** If you override this method, you might receive a serialized dtype config, which is a `dict`. You can deserialize it as follows:

    if "dtype" in config and isinstance(config["dtype"], dict):
        policy = dtype_policies.deserialize(config["dtype"])

<br />

<br />

<br />

| Args ||
|---|---|
| `config` | A Python dictionary, typically the output of `get_config`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An operation instance. ||

<br />