tfm.vision.layers.GlobalAveragePool3D

Creates a global average pooling layer with causal mode.

Implements causal mode, which runs a cumulative sum (with tf.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.

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.

Methods

call

View source

Calls the layer with the given inputs.

Args
inputs An input 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.

Returns
An output 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).

Raises
ValueError If using 'channels_first' data format.