<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/modeling/layers/nn_layers.py#L650-L781) |

Creates a global average pooling layer with causal mode.

    tfm.vision.layers.GlobalAveragePool3D(
        keepdims: bool = False,
        causal: bool = False,
        state_prefix: Optional[str] = None,
        **kwargs
    )

Implements causal mode, which runs a cumulative sum (with [`tf.cumsum`](https://www.tensorflow.org/api_docs/python/tf/math/cumsum)) across
frames in the time dimension, allowing the use of a stream buffer. Sums any
valid input state with the current input to allow state to accumulate over
several iterations.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `keepdims` | A `bool`. If True, keep the averaged dimensions. |
| `causal` | A `bool` of whether to run in causal mode with a cumulative sum across frames. |
| `state_prefix` | a prefix string to identify states. |
| `**kwargs` | Additional keyword arguments to be passed to this layer. |

<br />

## Methods

### `call`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/modeling/layers/nn_layers.py#L697-L781)

    call(
        inputs: tf.Tensor,
        states: Optional[States] = None,
        output_states: bool = False
    ) -> Union[tf.Tensor, Tuple[tf.Tensor, States]]

Calls the layer with the given inputs.

<br />

<br />

<br />

| Args ||
|---|---|
| `inputs` | An input [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor). |
| `states` | A `dict` of states such that, if any of the keys match for this layer, will overwrite the contents of the buffer(s). Expected keys include `state_prefix + '__pool_buffer'` and `state_prefix + '__pool_frame_count'`. |
| `output_states` | A `bool`. If True, returns the output tensor and output states. Returns just the output tensor otherwise. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An output [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) (and optionally the states if `output_states=True`). If `causal=True`, the output tensor will have shape `[batch_size, num_frames, 1, 1, channels]` if `keepdims=True`. We keep the frame dimension in this case to simulate a cumulative global average as if we are inputting one frame at a time. If `causal=False`, the output is equivalent to `tf_keras.layers.GlobalAveragePooling3D` with shape `[batch_size, 1, 1, 1, channels]` if `keepdims=True` (plus the optional buffer stored in `states`). ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If using 'channels_first' data format. |

<br />