a
    Sic                     @   sZ   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 G dd deZdS )	z)Private base class for pooling 3D layers.    N)backend)Layer)	InputSpec)
conv_utilsc                       s>   e Zd ZdZd fdd	Zdd Zd	d
 Z fddZ  ZS )	Pooling3Da  Pooling layer for arbitrary pooling functions, for 3D inputs.

    This class only exists for code reuse. It will never be an exposed API.

    Args:
      pool_function: The pooling function to apply, e.g. `tf.nn.max_pool2d`.
      pool_size: An integer or tuple/list of 3 integers:
        (pool_depth, pool_height, pool_width)
        specifying the size of the pooling window.
        Can be a single integer to specify the same value for
        all spatial dimensions.
      strides: An integer or tuple/list of 3 integers,
        specifying the strides of the pooling operation.
        Can be a single integer to specify the same value for
        all spatial dimensions.
      padding: A string. The padding method, either 'valid' or 'same'.
        Case-insensitive.
      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, depth, height, width, channels)`
        while `channels_first` corresponds to
        inputs with shape `(batch, channels, depth, height, width)`.
      name: A string, the name of the layer.
    validchannels_lastNc                    s   t  jf d|i| |d u r&t }|d u r2|}|| _t|dd| _tj|dddd| _t	|| _
t|| _tdd| _d S )	Nname   	pool_sizestridesT)
allow_zero   )ndim)super__init__r   image_data_formatpool_functionr   normalize_tupler   r   normalize_paddingpaddingnormalize_data_formatdata_formatr   
input_spec)selfr   r   r   r   r   r	   kwargs	__class__ _/var/www/html/django/DPS/env/lib/python3.9/site-packages/keras/layers/pooling/base_pooling3d.pyr   6   s    
zPooling3D.__init__c                 C   sd   d| j  d }d| j d }| jdkr2t|d}| j|||| j d}| jdkr`t|d}|S )N)   channels_first)r      r
      r    )ksizer   r   )r   r#   r    r"   r
   )r   r   r   tf	transposer   r   upper)r   inputs
pool_shaper   outputsr   r   r   callN   s    

zPooling3D.callc                 C   s   t | }| jdkr2|d }|d }|d }n|d }|d }|d }t|| jd | j| jd }t|| jd | j| jd }t|| jd | j| jd }| jdkrt |d |d |||gS t |d ||||d gS d S )Nr!   r"   r
   r#   r    r   )	r%   TensorShapeas_listr   r   conv_output_lengthr   r   r   )r   input_shapelen_dim1len_dim2len_dim3r   r   r   compute_output_shapec   s0    


zPooling3D.compute_output_shapec                    s<   | j | j| j| jd}t  }tt| t|  S )N)r   r   r   r   )	r   r   r   r   r   
get_configdictlistitems)r   configbase_configr   r   r   r4      s    
zPooling3D.get_config)r   r   N)	__name__
__module____qualname____doc__r   r+   r3   r4   __classcell__r   r   r   r   r      s       r   )r=   tensorflow.compat.v2compatv2r%   kerasr   keras.engine.base_layerr   keras.engine.input_specr   keras.utilsr   r   r   r   r   r   <module>   s   