o
    7?e`                     @   s\   d Z ddlm  mZ ddlmZ ddlmZ ddl	m
Z
 e
ddG dd	 d	eZeZdS )
z Global average pooling 1D layer.    N)backend)GlobalPooling1D)keras_exportz#keras.layers.GlobalAveragePooling1Dzkeras.layers.GlobalAvgPool1Dc                       s6   e Zd ZdZd
 fdd	ZdddZddd	Z  ZS )GlobalAveragePooling1Da  Global average pooling operation for temporal data.

    Examples:

    >>> input_shape = (2, 3, 4)
    >>> x = tf.random.normal(input_shape)
    >>> y = tf.keras.layers.GlobalAveragePooling1D()(x)
    >>> print(y.shape)
    (2, 4)

    Args:
      data_format: A string,
        one of `channels_last` (default) or `channels_first`.
        The ordering of the dimensions in the inputs.
        `channels_last` corresponds to inputs with shape
        `(batch, steps, features)` while `channels_first`
        corresponds to inputs with shape
        `(batch, features, steps)`.
      keepdims: A boolean, whether to keep the temporal dimension or not.
        If `keepdims` is `False` (default), the rank of the tensor is reduced
        for spatial dimensions.
        If `keepdims` is `True`, the temporal dimension are retained with
        length 1.
        The behavior is the same as for `tf.reduce_mean` or `np.mean`.

    Call arguments:
      inputs: A 3D tensor.
      mask: Binary tensor of shape `(batch_size, steps)` indicating whether
        a given step should be masked (excluded from the average).

    Input shape:
      - If `data_format='channels_last'`:
        3D tensor with shape:
        `(batch_size, steps, features)`
      - If `data_format='channels_first'`:
        3D tensor with shape:
        `(batch_size, features, steps)`

    Output shape:
      - If `keepdims`=False:
        2D tensor with shape `(batch_size, features)`.
      - If `keepdims`=True:
        - If `data_format='channels_last'`:
          3D tensor with shape `(batch_size, 1, features)`
        - If `data_format='channels_first'`:
          3D tensor with shape `(batch_size, features, 1)`
    channels_lastc                    s    t  jdd|i| d| _d S )Ndata_formatT )super__init__Zsupports_masking)selfr   kwargs	__class__r   r/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/keras/src/layers/pooling/global_average_pooling1d.pyr
   O   s   
zGlobalAveragePooling1D.__init__Nc                 C   s   | j dkrdnd}|d ur9t||d j}t|| j dkr dnd}||9 }tj||| jdtj||| jd S tj	||| jdS )Nr         r   )Zaxiskeepdims)
r   tfcastZdtypeZexpand_dimsr   sumr   Z
reduce_summean)r   inputsmaskZ
steps_axisr   r   r   callS   s   zGlobalAveragePooling1D.callc                 C   s   d S Nr   )r   r   r   r   r   r   compute_maska   s   z#GlobalAveragePooling1D.compute_mask)r   r   )__name__
__module____qualname____doc__r
   r   r   __classcell__r   r   r   r   r      s
    0
r   )r   Ztensorflow.compat.v2compatv2r   Z	keras.srcr   Z.keras.src.layers.pooling.base_global_pooling1dr   Z tensorflow.python.util.tf_exportr   r   ZGlobalAvgPool1Dr   r   r   r   <module>   s   I