ó
¾÷Xc           @@  s8  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 d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d  e f d! „  ƒ  YZ d" e f d# „  ƒ  YZ d$ e f d% „  ƒ  YZ d& e f d' „  ƒ  YZ d( e f d) „  ƒ  YZ d* e f d+ „  ƒ  YZ e Z e Z e Z  e Z! e Z" e Z# e Z$ e Z% e Z& e Z' e Z( e Z) d, S(-   i    (   t   absolute_importi   (   t   backend(   t   Layer(   t	   InputSpec(   t
   conv_utils(   t
   interfacest
   _Pooling1Dc           B@  sD   e  Z d  Z d d d d „ Z d „  Z d „  Z d „  Z d „  Z RS(	   s4   Abstract class for different pooling 1D layers.
    i   t   validc         K@  sƒ   t  t |  ƒ j |   | d  k r+ | } n  t j | d d ƒ |  _ t j | d d ƒ |  _ t j | ƒ |  _	 t
 d d ƒ |  _ d  S(   Ni   t	   pool_sizet   stridest   ndimi   (   t   superR   t   __init__t   NoneR   t   normalize_tupleR   R	   t   normalize_paddingt   paddingR   t
   input_spec(   t   selfR   R	   R   t   kwargs(    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR      s    	c         C@  sB   t  j | d |  j d |  j |  j d ƒ } | d | | d f S(   Ni   i    i   (   R   t   conv_output_lengthR   R   R	   (   R   t   input_shapet   length(    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyt   compute_output_shape   s
    
c         C@  s
   t  ‚ d  S(   N(   t   NotImplementedError(   R   t   inputsR   R	   R   t   data_format(    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyt   _pooling_function    s    c         C@  s]   t  j | d ƒ } |  j d | d |  j d	 d |  j d
 d |  j d d ƒ } t  j | d ƒ S(   Ni   R   R   i   R	   R   R   t   channels_last(   i   (   i   (   t   Kt   expand_dimsR   R   R	   R   t   squeeze(   R   R   t   output(    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyt   call$   s    		c         C@  s_   i |  j  d 6|  j d 6|  j d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR	   R   R   (	   R	   R   R   R   R   t
   get_configt   dictt   listt   items(   R   t   configt   base_config(    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR"   -   s
    
N(	   t   __name__t
   __module__t   __doc__R   R   R   R   R!   R"   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR      s   					t   MaxPooling1Dc           B@  s2   e  Z d  Z e j d d d d „ ƒ Z d „  Z RS(   s  Max pooling operation for temporal data.

    # Arguments
        pool_size: Integer, size of the max pooling windows.
        strides: Integer, or None. Factor by which to downscale.
            E.g. 2 will halve the input.
            If None, it will default to `pool_size`.
        padding: One of `"valid"` or `"same"` (case-insensitive).

    # Input shape
        3D tensor with shape: `(batch_size, steps, features)`.

    # Output shape
        3D tensor with shape: `(batch_size, downsampled_steps, features)`.
    i   R   c         K@  s#   t  t |  ƒ j | | | |  d  S(   N(   R   R+   R   (   R   R   R	   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   F   s    c         C@  s%   t  j | | | | | d d ƒ} | S(   Nt	   pool_modet   max(   R   t   pool2d(   R   R   R   R	   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   L   s    N(   R(   R)   R*   R   t   legacy_pooling1d_supportR   R   R   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR+   5   s
   t   AveragePooling1Dc           B@  s2   e  Z d  Z e j d d d d „ ƒ Z d „  Z RS(   s  Average pooling for temporal data.

    # Arguments
        pool_size: Integer, size of the max pooling windows.
        strides: Integer, or None. Factor by which to downscale.
            E.g. 2 will halve the input.
            If None, it will default to `pool_size`.
        padding: One of `"valid"` or `"same"` (case-insensitive).

    # Input shape
        3D tensor with shape: `(batch_size, steps, features)`.

    # Output shape
        3D tensor with shape: `(batch_size, downsampled_steps, features)`.
    i   R   c         K@  s#   t  t |  ƒ j | | | |  d  S(   N(   R   R0   R   (   R   R   R	   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   d   s    c         C@  s%   t  j | | | | | d d ƒ} | S(   NR,   t   avg(   R   R.   (   R   R   R   R	   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   j   s    N(   R(   R)   R*   R   R/   R   R   R   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR0   S   s
   t
   _Pooling2Dc           B@  sG   e  Z d  Z d d	 d d	 d „ Z d „  Z d „  Z d „  Z d „  Z RS(
   s4   Abstract class for different pooling 2D layers.
    i   R   c         K@  s¤   t  t |  ƒ j |   t j | ƒ } | d  k r: | } n  t j | d d ƒ |  _ t j | d d ƒ |  _ t j	 | ƒ |  _
 t j | ƒ |  _ t d d ƒ |  _ d  S(   Ni   R   R	   R
   i   (   R   R2   R   R   t   normalize_data_formatR   R   R   R	   R   R   R   R   R   (   R   R   R	   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   u   s    	c         C@  sð   |  j  d k r& | d } | d } n& |  j  d k rL | d } | d } n  t j | |  j d |  j |  j d ƒ } t j | |  j d |  j |  j d ƒ } |  j  d k rÅ | d | d | | f S|  j  d k rì | d | | | d f Sd  S(   Nt   channels_firsti   i   R   i   i    (   R   R   R   R   R   R	   (   R   R   t   rowst   cols(    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR      s    

c         C@  s
   t  ‚ d  S(   N(   R   (   R   R   R   R	   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   ‘   s    c         C@  s:   |  j  d | d |  j d |  j d |  j d |  j ƒ } | S(   NR   R   R	   R   R   (   R   R   R	   R   R   (   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   •   s    			c         C@  si   i |  j  d 6|  j d 6|  j d 6|  j d 6} t t |  ƒ j ƒ  } t t | j	 ƒ  ƒ t | j	 ƒ  ƒ ƒ S(   NR   R   R	   R   (
   R   R   R	   R   R   R2   R"   R#   R$   R%   (   R   R&   R'   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR"      s    

(   i   i   N(	   R(   R)   R*   R   R   R   R   R!   R"   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR2   q   s   				t   MaxPooling2Dc           B@  s5   e  Z d  Z e j d d d d d „ ƒ Z d „  Z RS(   s°  Max pooling operation for spatial data.

    # Arguments
        pool_size: integer or tuple of 2 integers,
            factors by which to downscale (vertical, horizontal).
            (2, 2) will halve the input in both spatial dimension.
            If only one integer is specified, the same window length
            will be used for both dimensions.
        strides: Integer, tuple of 2 integers, or None.
            Strides values.
            If None, it will default to `pool_size`.
        padding: One of `"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, height, width, channels)` while `channels_first`
            corresponds to inputs with shape
            `(batch, channels, height, width)`.
            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
        - If `data_format='channels_last'`:
            4D tensor with shape:
            `(batch_size, rows, cols, channels)`
        - If `data_format='channels_first'`:
            4D tensor with shape:
            `(batch_size, channels, rows, cols)`

    # Output shape
        - If `data_format='channels_last'`:
            4D tensor with shape:
            `(batch_size, pooled_rows, pooled_cols, channels)`
        - If `data_format='channels_first'`:
            4D tensor with shape:
            `(batch_size, channels, pooled_rows, pooled_cols)`
    i   R   c         K@  s&   t  t |  ƒ j | | | | |  d  S(   N(   R   R7   R   (   R   R   R	   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   Ï   s    c         C@  s%   t  j | | | | | d d ƒ} | S(   NR,   R-   (   R   R.   (   R   R   R   R	   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   Õ   s    		(   i   i   N(   R(   R)   R*   R   t   legacy_pooling2d_supportR   R   R   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR7   ¦   s
   '	t   AveragePooling2Dc           B@  s5   e  Z d  Z e j d d d d d „ ƒ Z d „  Z RS(   s´  Average pooling operation for spatial data.

    # Arguments
        pool_size: integer or tuple of 2 integers,
            factors by which to downscale (vertical, horizontal).
            (2, 2) will halve the input in both spatial dimension.
            If only one integer is specified, the same window length
            will be used for both dimensions.
        strides: Integer, tuple of 2 integers, or None.
            Strides values.
            If None, it will default to `pool_size`.
        padding: One of `"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, height, width, channels)` while `channels_first`
            corresponds to inputs with shape
            `(batch, channels, height, width)`.
            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
        - If `data_format='channels_last'`:
            4D tensor with shape:
            `(batch_size, rows, cols, channels)`
        - If `data_format='channels_first'`:
            4D tensor with shape:
            `(batch_size, channels, rows, cols)`

    # Output shape
        - If `data_format='channels_last'`:
            4D tensor with shape:
            `(batch_size, pooled_rows, pooled_cols, channels)`
        - If `data_format='channels_first'`:
            4D tensor with shape:
            `(batch_size, channels, pooled_rows, pooled_cols)`
    i   R   c         K@  s&   t  t |  ƒ j | | | | |  d  S(   N(   R   R9   R   (   R   R   R	   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR     s    c         C@  s%   t  j | | | | | d d ƒ} | S(   NR,   R1   (   R   R.   (   R   R   R   R	   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR     s    (   i   i   N(   R(   R)   R*   R   R8   R   R   R   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR9   Ý   s
   '	t
   _Pooling3Dc           B@  sG   e  Z d  Z d d	 d d	 d „ Z d „  Z d „  Z d „  Z d „  Z RS(
   s4   Abstract class for different pooling 3D layers.
    i   R   c         K@  s•   t  t |  ƒ j |   | d  k r+ | } n  t j | d d ƒ |  _ t j | d d ƒ |  _ t j | ƒ |  _	 t j
 | ƒ |  _ t d d ƒ |  _ d  S(   Ni   R   R	   R
   i   (   R   R:   R   R   R   R   R   R	   R   R   R3   R   R   R   (   R   R   R	   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR     s    	c         C@  s3  |  j  d k r0 | d } | d } | d } n0 |  j  d k r` | d } | d } | d } n  t j | |  j d |  j |  j d ƒ } t j | |  j d |  j |  j d ƒ } t j | |  j d |  j |  j d ƒ } |  j  d k r| d | d | | | f S|  j  d k r/| d | | | | d f Sd  S(   NR4   i   i   i   R   i   i    (   R   R   R   R   R   R	   (   R   R   t   len_dim1t   len_dim2t   len_dim3(    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   "  s,    



	c         C@  s
   t  ‚ d  S(   N(   R   (   R   R   R   R	   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   :  s    c         C@  s:   |  j  d | d |  j d |  j d |  j d |  j ƒ } | S(   NR   R   R	   R   R   (   R   R   R	   R   R   (   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   >  s    			c         C@  si   i |  j  d 6|  j d 6|  j d 6|  j d 6} t t |  ƒ j ƒ  } t t | j	 ƒ  ƒ t | j	 ƒ  ƒ ƒ S(   NR   R   R	   R   (
   R   R   R	   R   R   R:   R"   R#   R$   R%   (   R   R&   R'   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR"   F  s    

(   i   i   i   N(	   R(   R)   R*   R   R   R   R   R!   R"   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR:     s   	
			t   MaxPooling3Dc           B@  s5   e  Z d  Z e j d d d d d „ ƒ Z d „  Z RS(   s’  Max pooling operation for 3D data (spatial or spatio-temporal).

    # Arguments
        pool_size: tuple of 3 integers,
            factors by which to downscale (dim1, dim2, dim3).
            (2, 2, 2) will halve the size of the 3D input in each dimension.
        strides: tuple of 3 integers, or None. Strides values.
        padding: One of `"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, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
            while `channels_first` corresponds to inputs with shape
            `(batch, 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
        - If `data_format='channels_last'`:
            5D tensor with shape:
            `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
        - If `data_format='channels_first'`:
            5D tensor with shape:
            `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`

    # Output shape
        - If `data_format='channels_last'`:
            5D tensor with shape:
            `(batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels)`
        - If `data_format='channels_first'`:
            5D tensor with shape:
            `(batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3)`
    i   R   c         K@  s&   t  t |  ƒ j | | | | |  d  S(   N(   R   R>   R   (   R   R   R	   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   t  s    c         C@  s%   t  j | | | | | d d ƒ} | S(   NR,   R-   (   R   t   pool3d(   R   R   R   R	   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   z  s    (   i   i   i   N(   R(   R)   R*   R   t   legacy_pooling3d_supportR   R   R   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR>   O  s
   #	t   AveragePooling3Dc           B@  s5   e  Z d  Z e j d d d d d „ ƒ Z d „  Z RS(   s–  Average pooling operation for 3D data (spatial or spatio-temporal).

    # Arguments
        pool_size: tuple of 3 integers,
            factors by which to downscale (dim1, dim2, dim3).
            (2, 2, 2) will halve the size of the 3D input in each dimension.
        strides: tuple of 3 integers, or None. Strides values.
        padding: One of `"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, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
            while `channels_first` corresponds to inputs with shape
            `(batch, 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
        - If `data_format='channels_last'`:
            5D tensor with shape:
            `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
        - If `data_format='channels_first'`:
            5D tensor with shape:
            `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`

    # Output shape
        - If `data_format='channels_last'`:
            5D tensor with shape:
            `(batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels)`
        - If `data_format='channels_first'`:
            5D tensor with shape:
            `(batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3)`
    i   R   c         K@  s&   t  t |  ƒ j | | | | |  d  S(   N(   R   RA   R   (   R   R   R	   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   ¦  s    c         C@  s%   t  j | | | | | d d ƒ} | S(   NR,   R1   (   R   R?   (   R   R   R   R	   R   R   R    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   ¬  s    		(   i   i   i   N(   R(   R)   R*   R   R@   R   R   R   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRA     s
   #	t   _GlobalPooling1Dc           B@  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s;   Abstract class for different global pooling 1D layers.
    c         K@  s,   t  t |  ƒ j |   t d d ƒ |  _ d  S(   NR
   i   (   R   RB   R   R   R   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   ¸  s    c         C@  s   | d | d f S(   Ni    i   (    (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   ¼  s    c         C@  s
   t  ‚ d  S(   N(   R   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   ¿  s    (   R(   R)   R*   R   R   R!   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRB   ´  s   		t   GlobalAveragePooling1Dc           B@  s   e  Z d  Z d „  Z RS(   sÝ   Global average pooling operation for temporal data.

    # Input shape
        3D tensor with shape: `(batch_size, steps, features)`.

    # Output shape
        2D tensor with shape:
        `(batch_size, channels)`
    c         C@  s   t  j | d d ƒS(   Nt   axisi   (   R   t   mean(   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   Î  s    (   R(   R)   R*   R!   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRC   Ã  s   	t   GlobalMaxPooling1Dc           B@  s   e  Z d  Z d „  Z RS(   sÙ   Global max pooling operation for temporal data.

    # Input shape
        3D tensor with shape: `(batch_size, steps, features)`.

    # Output shape
        2D tensor with shape:
        `(batch_size, channels)`
    c         C@  s   t  j | d d ƒS(   NRD   i   (   R   R-   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   Ý  s    (   R(   R)   R*   R!   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRF   Ò  s   	t   _GlobalPooling2Dc           B@  s>   e  Z d  Z e j d d „ ƒ Z d „  Z d „  Z d „  Z	 RS(   s;   Abstract class for different global pooling 2D layers.
    c         K@  s>   t  t |  ƒ j |   t j | ƒ |  _ t d d ƒ |  _ d  S(   NR
   i   (   R   RG   R   R   R3   R   R   R   (   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   å  s    c         C@  s7   |  j  d k r! | d | d f S| d | d f Sd  S(   NR   i    i   i   (   R   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   ë  s    c         C@  s
   t  ‚ d  S(   N(   R   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   ñ  s    c         C@  sK   i |  j  d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR   (   R   R   RG   R"   R#   R$   R%   (   R   R&   R'   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR"   ô  s    N(
   R(   R)   R*   R   t   legacy_global_pooling_supportR   R   R   R!   R"   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRG   á  s   		t   GlobalAveragePooling2Dc           B@  s   e  Z d  Z d „  Z RS(   sé  Global average pooling operation for spatial data.

    # Arguments
        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, height, width, channels)` while `channels_first`
            corresponds to inputs with shape
            `(batch, channels, height, width)`.
            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
        - If `data_format='channels_last'`:
            4D tensor with shape:
            `(batch_size, rows, cols, channels)`
        - If `data_format='channels_first'`:
            4D tensor with shape:
            `(batch_size, channels, rows, cols)`

    # Output shape
        2D tensor with shape:
        `(batch_size, channels)`
    c         C@  sE   |  j  d k r( t j | d d d g ƒSt j | d d d g ƒSd  S(   NR   RD   i   i   i   (   R   R   RE   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!     s    (   R(   R)   R*   R!   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRI   ú  s   t   GlobalMaxPooling2Dc           B@  s   e  Z d  Z d „  Z RS(   så  Global max pooling operation for spatial data.

    # Arguments
        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, height, width, channels)` while `channels_first`
            corresponds to inputs with shape
            `(batch, channels, height, width)`.
            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
        - If `data_format='channels_last'`:
            4D tensor with shape:
            `(batch_size, rows, cols, channels)`
        - If `data_format='channels_first'`:
            4D tensor with shape:
            `(batch_size, channels, rows, cols)`

    # Output shape
        2D tensor with shape:
        `(batch_size, channels)`
    c         C@  sE   |  j  d k r( t j | d d d g ƒSt j | d d d g ƒSd  S(   NR   RD   i   i   i   (   R   R   R-   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   9  s    (   R(   R)   R*   R!   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRJ     s   t   _GlobalPooling3Dc           B@  s>   e  Z d  Z e j d d „ ƒ Z d „  Z d „  Z d „  Z	 RS(   s;   Abstract class for different global pooling 3D layers.
    c         K@  s>   t  t |  ƒ j |   t j | ƒ |  _ t d d ƒ |  _ d  S(   NR
   i   (   R   RK   R   R   R3   R   R   R   (   R   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   D  s    c         C@  s7   |  j  d k r! | d | d f S| d | d f Sd  S(   NR   i    i   i   (   R   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR   J  s    c         C@  s
   t  ‚ d  S(   N(   R   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   P  s    c         C@  sK   i |  j  d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR   (   R   R   RK   R"   R#   R$   R%   (   R   R&   R'   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR"   S  s    N(
   R(   R)   R*   R   RH   R   R   R   R!   R"   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRK   @  s   		t   GlobalAveragePooling3Dc           B@  s   e  Z d  Z d „  Z RS(   sV  Global Average pooling operation for 3D data.

    # Arguments
        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, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
            while `channels_first` corresponds to inputs with shape
            `(batch, 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
        - If `data_format='channels_last'`:
            5D tensor with shape:
            `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
        - If `data_format='channels_first'`:
            5D tensor with shape:
            `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`

    # Output shape
        2D tensor with shape:
        `(batch_size, channels)`
    c         C@  sK   |  j  d k r+ t j | d d d d g ƒSt j | d d d d g ƒSd  S(   NR   RD   i   i   i   i   (   R   R   RE   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   u  s    (   R(   R)   R*   R!   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRL   Y  s   t   GlobalMaxPooling3Dc           B@  s   e  Z d  Z d „  Z RS(   sR  Global Max pooling operation for 3D data.

    # Arguments
        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, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
            while `channels_first` corresponds to inputs with shape
            `(batch, 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
        - If `data_format='channels_last'`:
            5D tensor with shape:
            `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
        - If `data_format='channels_first'`:
            5D tensor with shape:
            `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`

    # Output shape
        2D tensor with shape:
        `(batch_size, channels)`
    c         C@  sK   |  j  d k r+ t j | d d d d g ƒSt j | d d d d g ƒSd  S(   NR   RD   i   i   i   i   (   R   R   R-   (   R   R   (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyR!   ˜  s    (   R(   R)   R*   R!   (    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyRM   |  s   N(*   t
   __future__R    t    R   R   t   engineR   R   t   utilsR   t   legacyR   R   R+   R0   R2   R7   R9   R:   R>   RA   RB   RC   RF   RG   RI   RJ   RK   RL   RM   t	   AvgPool1Dt	   MaxPool1Dt	   AvgPool2Dt	   MaxPool2Dt	   AvgPool3Dt	   MaxPool3Dt   GlobalMaxPool1Dt   GlobalMaxPool2Dt   GlobalMaxPool3Dt   GlobalAvgPool1Dt   GlobalAvgPool2Dt   GlobalAvgPool3D(    (    (    s3   /tmp/pip-build-isqEY4/keras/keras/layers/pooling.pyt   <module>   sF   *576<23###%