
    &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.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)`
       r   r   Nc                      t                      j        di | t          j        |          | _        t          j        |dd          | _        t          d          | _	        d S )N   size   )ndim )
super__init__r   standardize_data_formatdata_formatr   standardize_tupler   r   
input_spec)selfr   r   kwargs	__class__s       e/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/layers/reshaping/up_sampling3d.pyr   zUpSampling3D.__init__8   s_    ""6"""":;GG'9$6JJ	#+++    c                    | j         dk    rs|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_firstr   r   r         )r   r   )r   input_shapedim1dim2dim3s        r   compute_output_shapez!UpSampling3D.compute_output_shape>   sI   /// q>- 	!{1~--  q>- 	!{1~--  q>- 	!{1~-- 
  NKND$EE q>- 	!{1~--  q>- 	!{1~--  q>- 	!{1~-- 
  ND$k!nEEr   c                     |                      || j        d         | j        d         | j        d         | j                  S )Nr   r    r   )_resize_volumesr   r   )r   inputss     r   callzUpSampling3D.callb   s:    ##DIaL$)A,	!d>N
 
 	
r   c                 n    | 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   s:    )D4DEEgg((**(+(((r   c                 Z   |dk    rGt          j        ||d          }t          j        ||d          }t          j        ||d          }|S |dk    rGt          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     ***Z<a888FZA>>>FZ1===FMO++Z<a888FZA>>>FZ1===FMB[BBCCCr   )r   N)
__name__
__module____qualname____doc__r   r&   r*   r,   r(   __classcell__)r   s   @r   r
   r
   	   s        + +Z, , , , , ,"F "F "FH
 
 

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