a
    Sic                     @   sb   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 edG dd	 d	eZdS )
z"Keras cropping layer for 1D input.    N)Layer)	InputSpec)
conv_utils)keras_exportzkeras.layers.Cropping1Dc                       s>   e Zd ZdZd fdd	Zdd Zdd Z fd	d
Z  ZS )
Cropping1Dax  Cropping layer for 1D input (e.g. temporal sequence).

    It crops along the time dimension (axis 1).

    Examples:

    >>> input_shape = (2, 3, 2)
    >>> 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.Cropping1D(cropping=1)(x)
    >>> print(y)
    tf.Tensor(
      [[[2 3]]
       [[8 9]]], shape=(2, 1, 2), dtype=int64)

    Args:
      cropping: Int or tuple of int (length 2)
        How many units should be trimmed off at the beginning and end of
        the cropping dimension (axis 1).
        If a single int is provided, the same value will be used for both.

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

    Output shape:
      3D tensor with shape `(batch_size, cropped_axis, features)`
       r   c                    s6   t  jf i | tj|dddd| _tdd| _d S )N   croppingT)Z
allow_zero   )ndim)super__init__r   normalize_tupler
   r   
input_spec)selfr
   kwargs	__class__ ]/var/www/html/django/DPS/env/lib/python3.9/site-packages/keras/layers/reshaping/cropping1d.pyr   @   s
    zCropping1D.__init__c                 C   sT   t | }|d d ur8|d | jd  | jd  }nd }t |d ||d gS )Nr   r   r	   )tfTensorShapeas_listr
   )r   input_shapelengthr   r   r   compute_output_shapeG   s
    zCropping1D.compute_output_shapec                 C   s   |j d d ur:t| j|j d kr:td|j  d| j | jd dkrh|d d | jd d d d f S |d d | jd | jd  d d f S d S )Nr   zbcropping parameter of Cropping layer must be greater than the input shape. Received: inputs.shape=z, and cropping=r   )shapesumr
   
ValueError)r   inputsr   r   r   callO   s     zCropping1D.callc                    s0   d| j i}t  }tt| t|  S )Nr
   )r
   r   
get_configdictlistitems)r   configbase_configr   r   r   r"   ^   s    

zCropping1D.get_config)r   )	__name__
__module____qualname____doc__r   r   r!   r"   __classcell__r   r   r   r   r      s
   "r   )r+   tensorflow.compat.v2compatv2r   keras.engine.base_layerr   keras.engine.input_specr   keras.utilsr    tensorflow.python.util.tf_exportr   r   r   r   r   r   <module>   s   