o
    Ne                     @   sn   d Z ddlm  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 )z&Keras zero-padding layer for 1D input.    N)backend)Layer)	InputSpec)
conv_utils)keras_exportz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).

    Examples:

    >>> input_shape = (2, 2, 3)
    >>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
    >>> print(x)
    [[[ 0  1  2]
      [ 3  4  5]]
     [[ 6  7  8]
      [ 9 10 11]]]
    >>> y = tf.keras.layers.ZeroPadding1D(padding=2)(x)
    >>> print(y)
    tf.Tensor(
      [[[ 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]]], shape=(2, 6, 3), dtype=int64)

    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 int (length 2):
            How many zeros to add at the beginning and the end of
            the padding dimension (`(left_pad, right_pad)`).

    Input shape:
        3D tensor with shape `(batch_size, axis_to_pad, features)`

    Output shape:
        3D tensor with shape `(batch_size, padded_axis, features)`
       c                    s6   t  jdi | tj|dddd| _tdd| _d S )N   paddingT)Z
allow_zero   )ndim )super__init__r   Znormalize_tupler
   r   Z
input_spec)selfr
   kwargs	__class__r   UD:\Projects\ConvertPro\env\Lib\site-packages\keras/layers/reshaping/zero_padding1d.pyr   J   s
   zZeroPadding1D.__init__c                 C   sF   |d d ur|d | j d  | j d  }nd }t|d ||d gS )Nr   r   r	   )r
   tfZTensorShape)r   Zinput_shapelengthr   r   r   compute_output_shapeQ   s   z"ZeroPadding1D.compute_output_shapec                 C   s   t j|| jdS )N)r
   )r   Ztemporal_paddingr
   )r   Zinputsr   r   r   callX   s   zZeroPadding1D.callc                    s0   d| j i}t  }tt| t|  S )Nr
   )r
   r   
get_configdictlistitems)r   configZbase_configr   r   r   r   [   s   

zZeroPadding1D.get_config)r   )	__name__
__module____qualname____doc__r   r   r   r   __classcell__r   r   r   r   r      s    +r   )r!   Ztensorflow.compat.v2compatv2r   Zkerasr   Zkeras.engine.base_layerr   Zkeras.engine.input_specr   Zkeras.utilsr   Z tensorflow.python.util.tf_exportr   r   r   r   r   r   <module>   s   