
    &Vf                         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d
S )    )backend)ops)keras_export)	InputSpec)Layer)argument_validationzkeras.layers.ZeroPadding3Dc                   <     e Zd ZdZ	 d fd	Zd Zd Z fdZ xZS )	ZeroPadding3Da  Zero-padding layer for 3D data (spatial or spatio-temporal).

    Example:

    >>> input_shape = (1, 1, 2, 2, 3)
    >>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
    >>> y = keras.layers.ZeroPadding3D(padding=2)(x)
    >>> y.shape
    (1, 5, 6, 6, 3)

    Args:
        padding: Int, or tuple of 3 ints, or tuple of 3 tuples of 2 ints.
            - If int: the same symmetric padding is applied to depth, height,
              and width.
            - If tuple of 3 ints: interpreted as three different symmetric
              padding values for depth, height, and width:
              `(symmetric_dim1_pad, symmetric_dim2_pad, symmetric_dim3_pad)`.
            - If tuple of 3 tuples of 2 ints: interpreted as
              `((left_dim1_pad, right_dim1_pad), (left_dim2_pad,
              right_dim2_pad), (left_dim3_pad, right_dim3_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, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
            while `"channels_first"` corresponds to inputs with shape
            `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.
            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:
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
          `(batch_size, first_axis_to_pad, second_axis_to_pad,
          third_axis_to_pad, depth)`
        - If `data_format` is `"channels_first"`:
          `(batch_size, depth, first_axis_to_pad, second_axis_to_pad,
          third_axis_to_pad)`

    Output shape:
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
          `(batch_size, first_padded_axis, second_padded_axis,
          third_axis_to_pad, depth)`
        - If `data_format` is `"channels_first"`:
          `(batch_size, depth, first_padded_axis, second_padded_axis,
          third_axis_to_pad)`
       r   r   r   Nc                 >    t                      j        di | t          j        |          | _        t          |t                    r||f||f||ff| _        nt          |d          rt          |          dk    rt          d| d          t          j        |d         ddd	          }t          j        |d
         ddd	          }t          j        |d         ddd	          }|||f| _        nt          d| d          t          d          | _        d S )N__len__   z,`padding` should have 3 elements. Received: .r      z1st entry of paddingT)
allow_zeror   z2nd entry of paddingz3rd entry of paddinga  `padding` should be either an int, a tuple of 3 ints (symmetric_dim1_pad, symmetric_dim2_pad, symmetric_dim3_pad), or a tuple of 3 tuples of 2 ints ((left_dim1_pad, right_dim1_pad), (left_dim2_pad, right_dim2_pad), (left_dim3_pad, right_dim2_pad)). Received: padding=   )ndim )super__init__r   standardize_data_formatdata_format
isinstanceintpaddinghasattrlen
ValueErrorr   standardize_tupler   
input_spec)selfr   r   kwargsdim1_paddingdim2_paddingdim3_padding	__class__s          f/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/layers/reshaping/zero_padding3d.pyr   zZeroPadding3D.__init__<   sy    	""6"""":;GGgs## 	'"'"'"DLL
 Wi(( 	7||q   M7MMM   /@
A5$  L /@
A5$  L /@
A5$  L ),EDLL0 &-0 0 0   $+++    c                    t          |          }| j        dk    rdnd}t          dd          D ]E}|||z            8|||z   xx         | j        |         d         | j        |         d         z   z  cc<   Ft	          |          S )Nchannels_firstr   r   r   r   )listr   ranger   tuple)r#   input_shapeoutput_shapespatial_dims_offsetindexs        r)   compute_output_shapez"ZeroPadding3D.compute_output_shapeb   s    K((#'#37G#G#GaaQ1a[[ 	 	EE$778DU%88999L'*T\%-@-CC999 \"""r*   c                 v    | j         dk    rddg| j        R }ndg| j        dR }t          j        ||          S )Nr,   )r   r   )r   r   r   pad)r#   inputsall_dims_paddings      r)   callzZeroPadding3D.calll   sT    /// &>>> &>>v>>wv/000r*   c                 n    | j         | j        d}t                                                      }i ||S )N)r   r   )r   r   r   
get_config)r#   configbase_configr(   s      r)   r;   zZeroPadding3D.get_configs   s:    !\$:JKKgg((**(+(((r*   )r   N)	__name__
__module____qualname____doc__r   r4   r9   r;   __classcell__)r(   s   @r)   r
   r
   	   s        / /d =A$, $, $, $, $, $,L# # #1 1 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>rH      s                - - - - - - 1 1 1 1 1 1 ( ( ( ( ( ( / / / / / / *++l) l) l) l) l)E l) l) ,+l) l) l)r*   