
    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SKJr  \" S	5       " S
 S\5      5       rg)z%Keras upsampling layer for 2D inputs.    N)backend)Layer)	InputSpec)
conv_utils)image_utils)keras_exportzkeras.layers.UpSampling2Dc                   J   ^  \ 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
$ )	UpSampling2D   a  Upsampling layer for 2D inputs.

Repeats the rows and columns of the data
by `size[0]` and `size[1]` respectively.

Examples:

>>> input_shape = (2, 2, 1, 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.UpSampling2D(size=(1, 2))(x)
>>> print(y)
tf.Tensor(
  [[[[ 0  1  2]
     [ 0  1  2]]
    [[ 3  4  5]
     [ 3  4  5]]]
   [[[ 6  7  8]
     [ 6  7  8]]
    [[ 9 10 11]
     [ 9 10 11]]]], shape=(2, 2, 2, 3), dtype=int64)

Args:
  size: Int, or tuple of 2 integers.
    The upsampling factors for rows and columns.
  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'.
  interpolation: A string, one of `"area"`, `"bicubic"`, `"bilinear"`,
    `"gaussian"`, `"lanczos3"`, `"lanczos5"`, `"mitchellcubic"`,
    `"nearest"`.

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, upsampled_rows, upsampled_cols, channels)`
  - If `data_format` is `"channels_first"`:
      `(batch_size, channels, upsampled_rows, upsampled_cols)`
c                    > [         TU ]  " S0 UD6  [        R                  " U5      U l        [        R
                  " USS5      U l        [        R                  " U5      U l	        [        SS9U l        g )N   size   )ndim )super__init__r   normalize_data_formatdata_formatnormalize_tupler   r   get_interpolationinterpolationr   
input_spec)selfr   r   r   kwargs	__class__s        e/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/layers/reshaping/up_sampling2d.pyr   UpSampling2D.__init__[   s]     	"6"%;;KH..tQ?	(::=I#+    c                    [         R                  " U5      R                  5       nU R                  S:X  aY  US   b  U R                  S   US   -  OS nUS   b  U R                  S   US   -  OS n[         R                  " US   US   X#/5      $ US   b  U R                  S   US   -  OS nUS   b  U R                  S   US   -  OS n[         R                  " US   X#US   /5      $ )Nchannels_firstr   r         )tfTensorShapeas_listr   r   )r   input_shapeheightwidths       r   compute_output_shape!UpSampling2D.compute_output_shaped   s   nn[199;// q>- 		!{1~-  q>- 		!{1~- 
 >>QQ?  q>- 		!{1~-  q>- 		!{1~- 
 >>QA? r   c                     [         R                  " UU R                  S   U R                  S   U R                  U R                  S9$ )Nr   r#   )r   )r   resize_imagesr   r   r   )r   inputss     r   callUpSampling2D.call   s@    $$IIaLIIaL,,
 	
r   c                    > U R                   U R                  U R                  S.n[        TU ]  5       n[        [        UR                  5       5      [        UR                  5       5      -   5      $ )N)r   r   r   )r   r   r   r   
get_configdictlistitems)r   configbase_configr   s      r   r2   UpSampling2D.get_config   s[    II++!//

 g(*D**,-V\\^0DDEEr   )r   r   r   r   ))r   r   Nnearest)__name__
__module____qualname____firstlineno____doc__r   r*   r/   r2   __static_attributes____classcell__)r   s   @r   r
   r
      s*    9x <E,>
F Fr   r
   )r>   tensorflow.compat.v2compatv2r$   tf_keras.srcr   tf_keras.src.engine.base_layerr   tf_keras.src.engine.input_specr   tf_keras.src.utilsr   r    tensorflow.python.util.tf_exportr   r
   r   r   r   <module>rI      sM    , " !   0 4 ) * : )*tF5 tF +tFr   