
    6bi=                         S r SSKJs  Jr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  \" S5       " S	 S
\5      5       rg)z&Keras zero-padding layer for 2D input.    N)backend)Layer)	InputSpec)
conv_utils)keras_exportzkeras.layers.ZeroPadding2Dc                   H   ^  \ rS rSrSrSU 4S jjrS rS rU 4S jrSr	U =r
$ )	ZeroPadding2D   a  Zero-padding layer for 2D input (e.g. picture).

This layer can add rows and columns of zeros
at the top, bottom, left and right side of an image tensor.

Examples:

>>> input_shape = (1, 1, 2, 2)
>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
>>> print(x)
[[[[0 1]
   [2 3]]]]
>>> y = tf.keras.layers.ZeroPadding2D(padding=1)(x)
>>> print(y)
tf.Tensor(
  [[[[0 0]
     [0 0]
     [0 0]
     [0 0]]
    [[0 0]
     [0 1]
     [2 3]
     [0 0]]
    [[0 0]
     [0 0]
     [0 0]
     [0 0]]]], shape=(1, 3, 4, 2), dtype=int64)

Args:
  padding: Int, or tuple of 2 ints, or tuple of 2 tuples of 2 ints.
    - If int: the same symmetric padding
      is applied to height and width.
    - If tuple of 2 ints:
      interpreted as two different
      symmetric padding values for height and width:
      `(symmetric_height_pad, symmetric_width_pad)`.
    - If tuple of 2 tuples of 2 ints:
      interpreted as
      `((top_pad, bottom_pad), (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, height, width, channels)` while `channels_first`
    corresponds to inputs with shape
    `(batch_size, channels, height, width)`.
    When unspecified, uses
    `image_data_format` value found in your TF-Keras config file at
     `~/.keras/keras.json` (if exists) else 'channels_last'.
    Defaults to 'channels_last'.

Input shape:
  4D tensor with shape:
  - If `data_format` is `"channels_last"`:
      `(batch_size, rows, cols, channels)`
  - If `data_format` is `"channels_first"`:
      `(batch_size, channels, rows, cols)`

Output shape:
  4D tensor with shape:
  - If `data_format` is `"channels_last"`:
      `(batch_size, padded_rows, padded_cols, channels)`
  - If `data_format` is `"channels_first"`:
      `(batch_size, channels, padded_rows, padded_cols)`
c                   > [         TU ]  " S0 UD6  [        R                  " U5      U l        [        U[        5      (       a  X4X44U l        O{[        US5      (       a[  [        U5      S:w  a  [        SU S35      e[        R                  " US   SSSS9n[        R                  " US	   SS
SS9nXE4U l        O[        SU S35      e[        SS9U l        g )N__len__   z.`padding` should have two elements. Received: .r   z1st entry of paddingT)
allow_zero   z2nd entry of paddingz`padding` should be either an int, a tuple of 2 ints (symmetric_height_pad, symmetric_width_pad), or a tuple of 2 tuples of 2 ints ((top_pad, bottom_pad), (left_pad, right_pad)). Received:    )ndim )super__init__r   normalize_data_formatdata_format
isinstanceintpaddinghasattrlen
ValueErrornormalize_tupler   
input_spec)selfr   r   kwargsheight_paddingwidth_padding	__class__s         f/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/layers/reshaping/zero_padding2d.pyr   ZeroPadding2D.__init__a   s    "6"%;;KHgs##$.0BCDLWi((7|q  DWIQO  (77
A5$N '66
A5$M +:DL
 %IQ(  $+    c                    [         R                  " U5      R                  5       nU R                  S:X  a  US   b,  US   U R                  S   S   -   U R                  S   S   -   nOS nUS   b,  US   U R                  S   S   -   U R                  S   S   -   nOS n[         R                  " US   US   X#/5      $ U R                  S:X  a  US   b,  US   U R                  S   S   -   U R                  S   S   -   nOS nUS   b,  US   U R                  S   S   -   U R                  S   S   -   nOS n[         R                  " US   X#US   /5      $ g )Nchannels_firstr   r   r      channels_last)tfTensorShapeas_listr   r   )r    input_shaperowscolss       r%   compute_output_shape"ZeroPadding2D.compute_output_shape}   sg   nn[199;//1~)"1~Q(::T\\!_Q=OO1~)"1~Q(::T\\!_Q=OO>>;q>;q>4"NOO01~)"1~Q(::T\\!_Q=OO1~)"1~Q(::T\\!_Q=OO>>;q>4{1~"NOO 1r'   c                 T    [         R                  " XR                  U R                  S9$ N)r   r   )r   spatial_2d_paddingr   r   )r    inputss     r%   callZeroPadding2D.call   s$    ))LLd6F6F
 	
r'   c                    > U R                   U R                  S.n[        TU ]  5       n[	        [        UR                  5       5      [        UR                  5       5      -   5      $ r5   )r   r   r   
get_configdictlistitems)r    configbase_configr$   s      r%   r;   ZeroPadding2D.get_config   sM    !\\$:J:JKg(*D**,-V\\^0DDEEr'   )r   r   r   ))r   r   N)__name__
__module____qualname____firstlineno____doc__r   r2   r8   r;   __static_attributes____classcell__)r$   s   @r%   r	   r	      s&    @D,8P.

F Fr'   r	   )rF   tensorflow.compat.v2compatv2r,   tf_keras.srcr   tf_keras.src.engine.base_layerr   tf_keras.src.engine.input_specr   tf_keras.src.utilsr    tensorflow.python.util.tf_exportr   r	   r   r'   r%   <module>rQ      sJ    - " !   0 4 ) : *+~FE ~F ,~Fr'   