o
    2h"                     @   sd   d dl mZ d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 edG dd	 d	eZd
S )    )backend)ops)keras_export)	InputSpec)Layer)argument_validationzkeras.layers.ZeroPadding1Dc                       s>   e Zd ZdZd fdd	Zdd Zdd	 Z fd
dZ  ZS )ZeroPadding1Da  Zero-padding layer for 1D input (e.g. temporal sequence).

    Example:

    >>> input_shape = (2, 2, 3)
    >>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
    >>> x
    [[[ 0  1  2]
      [ 3  4  5]]
     [[ 6  7  8]
      [ 9 10 11]]]
    >>> y = keras.layers.ZeroPadding1D(padding=2)(x)
    >>> y
    [[[ 0  0  0]
      [ 0  0  0]
      [ 0  1  2]
      [ 3  4  5]
      [ 0  0  0]
      [ 0  0  0]]
     [[ 0  0  0]
      [ 0  0  0]
      [ 6  7  8]
      [ 9 10 11]
      [ 0  0  0]
      [ 0  0  0]]]

    Args:
        padding: Int, or tuple of int (length 2), or dictionary.
            - If int: how many zeros to add at the beginning and end of
              the padding dimension (axis 1).
            - If tuple of 2 ints: how many zeros to add at the beginning and the
              end of the padding dimension (`(left_pad, right_pad)`).
        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_size, axis_to_pad, channels)` while `"channels_first"`
            corresponds to inputs with shape
            `(batch_size, channels, axis_to_pad)`.
            When unspecified, uses `image_data_format` value found in your Keras
            config file at `~/.keras/keras.json` (if exists). Defaults to
            `"channels_last"`.

    Input shape:
        3D tensor with shape:
        - If `data_format` is `"channels_last"`:
          `(batch_size, axis_to_pad, features)`
        - If `data_format` is `"channels_first"`:
          `(batch_size, features, axis_to_pad)`

    Output shape:
        3D tensor with shape:
        - If `data_format` is `"channels_last"`:
          `(batch_size, padded_axis, features)`
        - If `data_format` is `"channels_first"`:
          `(batch_size, features, padded_axis)`
       Nc                    sB   t  jdi | t|| _tj|dddd| _tdd| _	d S )N   paddingT)
allow_zero   )ndim )
super__init__r   standardize_data_formatdata_formatr   standardize_tupler   r   
input_spec)selfr   r   kwargs	__class__r   d/var/www/html/chatgem/venv/lib/python3.10/site-packages/keras/src/layers/reshaping/zero_padding1d.pyr   D   s   zZeroPadding1D.__init__c                 C   sN   t |}| jdkrdnd}|| d ur#||  | jd | jd  7  < t|S )Nchannels_firstr
   r	   r   )listr   r   tuple)r   input_shapeoutput_shapepadding_dimr   r   r   compute_output_shapeL   s
    z"ZeroPadding1D.compute_output_shapec                 C   s0   | j dkrdd| jf}nd| jdf}t||S )Nr   )r   r   )r   r   r   pad)r   inputsall_dims_paddingr   r   r   callS   s   
zZeroPadding1D.callc                    s$   | j | jd}t  }i ||S )N)r   r   )r   r   r   
get_config)r   configbase_configr   r   r   r&   Z   s   
zZeroPadding1D.get_config)r	   N)	__name__
__module____qualname____doc__r   r!   r%   r&   __classcell__r   r   r   r   r   	   s    9r   N)	keras.srcr   r   keras.src.api_exportr   keras.src.layers.input_specr   keras.src.layers.layerr   keras.src.utilsr   r   r   r   r   r   <module>   s    