
    2Vh.                     x    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y
)    )backend)ops)keras_export)	InputSpec)Layer)argument_validationzkeras.layers.UpSampling3Dc                   @     e Zd ZdZd fd	Zd Zd Z fdZd Z xZ	S )UpSampling3Da  Upsampling layer for 3D inputs.

    Repeats the 1st, 2nd and 3rd dimensions
    of the data by `size[0]`, `size[1]` and `size[2]` respectively.

    Example:

    >>> input_shape = (2, 1, 2, 1, 3)
    >>> x = np.ones(input_shape)
    >>> y = keras.layers.UpSampling3D(size=(2, 2, 2))(x)
    >>> y.shape
    (2, 2, 4, 2, 3)

    Args:
        size: Int, or tuple of 3 integers.
            The upsampling factors for dim1, dim2 and dim3.
        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) else `"channels_last"`.
            Defaults to `"channels_last"`.

    Input shape:
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch_size, dim1, dim2, dim3, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch_size, channels, dim1, dim2, dim3)`

    Output shape:
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch_size, upsampled_dim1, upsampled_dim2, upsampled_dim3,
            channels)`
        - If `data_format` is `"channels_first"`:
            `(batch_size, channels, upsampled_dim1, upsampled_dim2,
            upsampled_dim3)`
    c                     t        |   di | t        j                  |      | _        t        j                  |dd      | _        t        d      | _	        y )N   size   )ndim )
super__init__r   standardize_data_formatdata_formatr   standardize_tupler   r   
input_spec)selfr   r   kwargs	__class__s       X/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/layers/reshaping/up_sampling3d.pyr   zUpSampling3D.__init__8   sH    "6""::;G'99$6J	#+    c                    | j                   dk(  ra|d   | j                  d   |d   z  nd }|d   | j                  d   |d   z  nd }|d   | j                  d   |d   z  nd }|d   |d   |||fS |d   | j                  d   |d   z  nd }|d   | j                  d   |d   z  nd }|d   | j                  d   |d   z  nd }|d   ||||d   fS )Nchannels_first   r   r         )r   r   )r   input_shapedim1dim2dim3s        r   compute_output_shapez!UpSampling3D.compute_output_shape>   sC   // q>- 		!{1~-  q>- 		!{1~-  q>- 		!{1~- 
  NKND$EE q>- 		!{1~-  q>- 		!{1~-  q>- 		!{1~- 
  ND$k!nEEr   c                     | j                  || j                  d   | j                  d   | j                  d   | j                        S )Nr   r   r   )_resize_volumesr   r   )r   inputss     r   callzUpSampling3D.callb   s>    ##DIIaL$))A,		!d>N>N
 	
r   c                 ^    | j                   | j                  d}t        |          }i ||S )N)r   r   )r   r   r   
get_config)r   configbase_configr   s      r   r+   zUpSampling3D.get_configg   s4    ))D4D4DEg(*(+(((r   c                 Z   |dk(  rJt        j                  ||d      }t        j                  ||d      }t        j                  ||d      }|S |dk(  rJt        j                  ||d      }t        j                  ||d      }t        j                  ||d      }|S t        d|       )	ak  Resizes the volume contained in a 5D tensor.

        Args:
            x: Tensor or variable to resize.
            depth_factor: Positive integer.
            height_factor: Positive integer.
            width_factor: Positive integer.
            data_format: One of `"channels_first"`, `"channels_last"`.

        Returns:
            Resized tensor.
        r   r   )axisr   r    channels_lastr   zInvalid data_format: )r   repeat
ValueError)r   xdepth_factorheight_factorwidth_factorr   outputs          r   r'   zUpSampling3D._resize_volumesl   s     **ZZ<a8FZZA>FZZ1=FMO+ZZ<a8FZZA>FZZ1=FM4[MBCCr   ))r   r   r   N)
__name__
__module____qualname____doc__r   r%   r)   r+   r'   __classcell__)r   s   @r   r
   r
   	   s%    +Z,"FH

)
D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>rB      s>      - 1 ( / )*|D5 |D +|Dr   