
    2Vh"                     x    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	e             Zy
)    )backend)ops)keras_export)	InputSpec)Layer)argument_validationzkeras.layers.ZeroPadding1Dc                   :     e Zd ZdZd fd	Zd Zd Z fdZ x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)`
    c                     t        |   di | t        j                  |      | _        t        j                  |ddd      | _        t        d      | _	        y )N   paddingT)
allow_zero   )ndim )
super__init__r   standardize_data_formatdata_formatr   standardize_tupler   r   
input_spec)selfr   r   kwargs	__class__s       Y/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/layers/reshaping/zero_padding1d.pyr   zZeroPadding1D.__init__D   sO    "6""::;G*<<Q	d
 $+    c                     t        |      }| j                  dk(  rdnd}||   *||xx   | j                  d   | j                  d   z   z  cc<   t        |      S )Nchannels_firstr      r   )listr   r   tuple)r   input_shapeoutput_shapepadding_dims       r   compute_output_shapez"ZeroPadding1D.compute_output_shapeL   s\    K(++/??aQ$0%a4<<?)JJ%\""r   c                     | j                   dk(  rdd| j                  f}nd| j                  df}t        j                  ||      S )Nr   )r   r   )r   r   r   pad)r   inputsall_dims_paddings      r   callzZeroPadding1D.callS   sE    // &= &f=wwv/00r   c                 ^    | j                   | j                  d}t        |          }i ||S )N)r   r   )r   r   r   
get_config)r   configbase_configr   s      r   r,   zZeroPadding1D.get_configZ   s4    !\\$:J:JKg(*(+(((r   )r   N)	__name__
__module____qualname____doc__r   r%   r*   r,   __classcell__)r   s   @r   r
   r
   	   s"    7r,#1) )r   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   <module>r9      s;      - 1 ( / *+S)E S) ,S)r   