a
    SicB                     @   sn   d Z ddlm  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
 d
eZdS )z%Keras upsampling layer for 3D inputs.    N)backend)Layer)	InputSpec)
conv_utils)keras_exportzkeras.layers.UpSampling3Dc                       s>   e Zd ZdZd fdd	Zdd Zdd	 Z fd
dZ  ZS )UpSampling3DaY  Upsampling layer for 3D inputs.

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

    Examples:

    >>> input_shape = (2, 1, 2, 1, 3)
    >>> x = tf.constant(1, shape=input_shape)
    >>> y = tf.keras.layers.UpSampling3D(size=2)(x)
    >>> print(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)`.
        It defaults to the `image_data_format` value found in your
        Keras config file at `~/.keras/keras.json`.
        If you never set it, then it will be "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                    s>   t || _t |dd| _tdd| _t jf i | d S )N   size   )ndim)	r   normalize_data_formatdata_formatnormalize_tupler   r   
input_specsuper__init__)selfr   r   kwargs	__class__ `/var/www/html/django/DPS/env/lib/python3.9/site-packages/keras/layers/reshaping/up_sampling3d.pyr   K   s    zUpSampling3D.__init__c                 C   s   t | }| jdkr|d d ur6| jd |d  nd }|d d urX| jd |d  nd }|d d urz| jd |d  nd }t |d |d |||gS |d d ur| jd |d  nd }|d d ur| jd |d  nd }|d d ur| jd |d  nd }t |d ||||d gS d S )Nchannels_firstr	   r   r
         )tfTensorShapeas_listr   r   )r   input_shapedim1dim2dim3r   r   r   compute_output_shapeQ   s@    






z!UpSampling3D.compute_output_shapec                 C   s&   t || jd | jd | jd | jS )Nr   r   r	   )r   resize_volumesr   r   )r   inputsr   r   r   callz   s    zUpSampling3D.callc                    s4   | j | jd}t  }tt| t|  S )N)r   r   )r   r   r   
get_configdictlistitems)r   configbase_configr   r   r   r(      s    
zUpSampling3D.get_config)r   N)	__name__
__module____qualname____doc__r   r$   r'   r(   __classcell__r   r   r   r   r      s
   ,)r   )r1   tensorflow.compat.v2compatv2r   kerasr   keras.engine.base_layerr   keras.engine.input_specr   keras.utilsr    tensorflow.python.util.tf_exportr   r   r   r   r   r   <module>   s   