ó
¾÷Xc           @@  s¢  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 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 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 d0 „  ƒ  YZ' d1 e
 f d2 „  ƒ  YZ( e Z) e Z* e Z+ e Z, e Z- e Z. Z/ e Z0 e Z1 d3 S(4   i    (   t   absolute_importi   (   t   backend(   t   activations(   t   initializers(   t   regularizers(   t   constraints(   t   Layer(   t	   InputSpec(   t
   conv_utils(   t
   interfacesi   (   t   AveragePooling1D(   t   AveragePooling2D(   t   AveragePooling3D(   t   MaxPooling1D(   t   MaxPooling2D(   t   MaxPooling3D(   t   AtrousConvolution1D(   t   AtrousConvolution2Dt   _Convc           B@  sb   e  Z d  Z d d d
 d d
 e d d d
 d
 d
 d
 d
 d „ Z d „  Z d „  Z d „  Z d	 „  Z	 RS(   sø  Abstract nD convolution layer (private, used as implementation base).

    This layer creates a convolution kernel that is convolved
    with the layer input to produce a tensor of outputs.
    If `use_bias` is True, a bias vector is created and added to the outputs.
    Finally, if `activation` is not `None`,
    it is applied to the outputs as well.

    # Arguments
        rank: An integer, the rank of the convolution,
            e.g. "2" for 2D convolution.
        filters: Integer, the dimensionality of the output space
            (i.e. the number output of filters in the convolution).
        kernel_size: An integer or tuple/list of n integers, specifying the
            dimensions of the convolution window.
        strides: An integer or tuple/list of n integers,
            specifying the strides of the convolution.
            Specifying any stride value != 1 is incompatible with specifying
            any `dilation_rate` value != 1.
        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, ..., channels)` while `channels_first` corresponds to
            inputs with shape `(batch, channels, ...)`.
            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".
        dilation_rate: An integer or tuple/list of n integers, specifying
            the dilation rate to use for dilated convolution.
            Currently, specifying any `dilation_rate` value != 1 is
            incompatible with specifying any `strides` value != 1.
        activation: Activation function to use
            (see [activations](../activations.md)).
            If you don't specify anything, no activation is applied
            (ie. "linear" activation: `a(x) = x`).
        use_bias: Boolean, whether the layer uses a bias vector.
        kernel_initializer: Initializer for the `kernel` weights matrix
            (see [initializers](../initializers.md)).
        bias_initializer: Initializer for the bias vector
            (see [initializers](../initializers.md)).
        kernel_regularizer: Regularizer function applied to
            the `kernel` weights matrix
            (see [regularizer](../regularizers.md)).
        bias_regularizer: Regularizer function applied to the bias vector
            (see [regularizer](../regularizers.md)).
        activity_regularizer: Regularizer function applied to
            the output of the layer (its "activation").
            (see [regularizer](../regularizers.md)).
        kernel_constraint: Constraint function applied to the kernel matrix
            (see [constraints](../constraints.md)).
        bias_constraint: Constraint function applied to the bias vector
            (see [constraints](../constraints.md)).
    i   t   validt   glorot_uniformt   zerosc         K@  sJ  t  t |  ƒ j |   | |  _ | |  _ t j | | d ƒ |  _ t j | | d ƒ |  _ t j	 | ƒ |  _
 t j | ƒ |  _ t j | | d ƒ |  _ t j | ƒ |  _ |	 |  _ t j |
 ƒ |  _ t j | ƒ |  _ t j | ƒ |  _ t j | ƒ |  _ t j | ƒ |  _ t j | ƒ |  _ t j | ƒ |  _ t d |  j d ƒ |  _ d  S(   Nt   kernel_sizet   stridest   dilation_ratet   ndimi   (   t   superR   t   __init__t   rankt   filtersR   t   normalize_tupleR   R   t   normalize_paddingt   paddingt   normalize_data_formatt   data_formatR   R   t   gett
   activationt   use_biasR   t   kernel_initializert   bias_initializerR   t   kernel_regularizert   bias_regularizert   activity_regularizerR   t   kernel_constraintt   bias_constraintR   t
   input_spec(   t   selfR   R   R   R   R    R"   R   R$   R%   R&   R'   R(   R)   R*   R+   R,   t   kwargs(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   S   s$    			c      
   C@  s  |  j  d k r d } n d } | | d  k r= t d ƒ ‚ n  | | } |  j | |  j f } |  j | d |  j d d d |  j d	 |  j ƒ|  _	 |  j
 rÕ |  j |  j f d |  j d d
 d |  j d	 |  j ƒ|  _ n	 d  |  _ t d |  j d d i | | 6ƒ |  _ t |  _ d  S(   Nt   channels_firsti   iÿÿÿÿsD   The channel dimension of the inputs should be defined. Found `None`.t   initializert   namet   kernelt   regularizert
   constraintt   biasR   i   t   axes(   R"   t   Nonet
   ValueErrorR   R   t
   add_weightR&   R(   R+   R3   R%   R'   R)   R,   R6   R   R   R-   t   Truet   built(   R.   t   input_shapet   channel_axist	   input_dimt   kernel_shape(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyt   buildw   s,    	
						c         C@  s3  |  j  d k rS t j | |  j d |  j d d |  j d |  j d |  j d ƒ} n  |  j  d k rž t j | |  j d |  j d |  j d |  j d |  j ƒ} n  |  j  d k ré t j	 | |  j d |  j d |  j d |  j d |  j ƒ} n  |  j
 rt j | |  j d |  j ƒ} n  |  j d  k	 r/|  j | ƒ S| S(	   Ni   R   i    R    R"   R   i   i   (   R   t   Kt   conv1dR3   R   R    R"   R   t   conv2dt   conv3dR%   t   bias_addR6   R$   R8   (   R.   t   inputst   outputs(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyt   call”   s@    													c         C@  sS  |  j  d k r« | d d !} g  } xg t t | ƒ ƒ D]S } t j | | |  j | d |  j d |  j | d |  j | ƒ} | j	 | ƒ q5 W| d f t
 | ƒ |  j f S|  j  d k rO| d	 } g  } xg t t | ƒ ƒ D]S } t j | | |  j | d |  j d |  j | d |  j | ƒ} | j	 | ƒ qÝ W| d |  j f t
 | ƒ Sd  S(
   Nt   channels_lasti   iÿÿÿÿR    t   stridet   dilationi    R0   i   (   R"   t   ranget   lenR   t   conv_output_lengthR   R    R   R   t   appendt   tupleR   (   R.   R=   t   spacet	   new_spacet   it   new_dim(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyt   compute_output_shape¸   s0    	
	c         C@  s)  i |  j  d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6t j |  j	 ƒ d 6|  j
 d	 6t j |  j ƒ d
 6t j |  j ƒ d 6t j |  j ƒ d 6t j |  j ƒ d 6t j |  j ƒ d 6t j |  j ƒ d 6t j |  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   R   R   R   R    R"   R   R   t	   serializeR$   R%   R   R&   R'   R   R(   R)   R*   R   R+   R,   R   R   t
   get_configt   dictt   listt   items(   R.   t   configt   base_config(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   Ò   s&    







N(
   t   __name__t
   __module__t   __doc__R8   R;   R   RA   RI   RV   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR      s$   7		$	t   Conv1Dc           B@  sM   e  Z d  Z e j d d d d e d d d d d d d d „ ƒ Z d „  Z RS(   s  1D convolution layer (e.g. temporal convolution).

    This layer creates a convolution kernel that is convolved
    with the layer input over a single spatial (or temporal) dimension
    to produce a tensor of outputs.
    If `use_bias` is True, a bias vector is created and added to the outputs.
    Finally, if `activation` is not `None`,
    it is applied to the outputs as well.

    When using this layer as the first layer in a model,
    provide an `input_shape` argument
    (tuple of integers or `None`, e.g.
    `(10, 128)` for sequences of 10 vectors of 128-dimensional vectors,
    or `(None, 128)` for variable-length sequences of 128-dimensional vectors.

    # Arguments
        filters: Integer, the dimensionality of the output space
            (i.e. the number output of filters in the convolution).
        kernel_size: An integer or tuple/list of a single integer,
            specifying the length of the 1D convolution window.
        strides: An integer or tuple/list of a single integer,
            specifying the stride length of the convolution.
            Specifying any stride value != 1 is incompatible with specifying
            any `dilation_rate` value != 1.
        padding: One of `"valid"`, `"causal"` or `"same"` (case-insensitive).
            `"causal"` results in causal (dilated) convolutions, e.g. output[t]
            depends solely on input[:t-1]. Useful when modeling temporal data
            where the model should not violate the temporal order.
            See [WaveNet: A Generative Model for Raw Audio, section 2.1](https://arxiv.org/abs/1609.03499).
        dilation_rate: an integer or tuple/list of a single integer, specifying
            the dilation rate to use for dilated convolution.
            Currently, specifying any `dilation_rate` value != 1 is
            incompatible with specifying any `strides` value != 1.
        activation: Activation function to use
            (see [activations](../activations.md)).
            If you don't specify anything, no activation is applied
            (ie. "linear" activation: `a(x) = x`).
        use_bias: Boolean, whether the layer uses a bias vector.
        kernel_initializer: Initializer for the `kernel` weights matrix
            (see [initializers](../initializers.md)).
        bias_initializer: Initializer for the bias vector
            (see [initializers](../initializers.md)).
        kernel_regularizer: Regularizer function applied to
            the `kernel` weights matrix
            (see [regularizer](../regularizers.md)).
        bias_regularizer: Regularizer function applied to the bias vector
            (see [regularizer](../regularizers.md)).
        activity_regularizer: Regularizer function applied to
            the output of the layer (its "activation").
            (see [regularizer](../regularizers.md)).
        kernel_constraint: Constraint function applied to the kernel matrix
            (see [constraints](../constraints.md)).
        bias_constraint: Constraint function applied to the bias vector
            (see [constraints](../constraints.md)).

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

    # Output shape
        3D tensor with shape: `(batch_size, new_steps, filters)`
        `steps` value might have changed due to padding or strides.
    i   R   R   R   c      "   K@  sŒ   t  t |  ƒ j d d d | d | d | d | d d d	 | d
 | d | d | d |	 d |
 d | d | d | d | |  t d d ƒ |  _ d  S(   NR   i   R   R   R   R    R"   RJ   R   R$   R%   R&   R'   R(   R)   R*   R+   R,   R   i   (   R   Ra   R   R   R-   (   R.   R   R   R   R    R   R$   R%   R&   R'   R(   R)   R*   R+   R,   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   )  s&    c         C@  s3   t  t |  ƒ j ƒ  } | j d ƒ | j d ƒ | S(   NR   R"   (   R   Ra   RX   t   pop(   R.   R\   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   M  s    N(	   R^   R_   R`   R	   t   legacy_conv1d_supportR8   R;   R   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRa   é   s   >t   Conv2Dc           B@  sP   e  Z d  Z e j d d d d	 d e d d d d d d d d „ ƒ Z d „  Z RS(
   s)  2D convolution layer (e.g. spatial convolution over images).

    This layer creates a convolution kernel that is convolved
    with the layer input to produce a tensor of
    outputs. If `use_bias` is True,
    a bias vector is created and added to the outputs. Finally, if
    `activation` is not `None`, it is applied to the outputs as well.

    When using this layer as the first layer in a model,
    provide the keyword argument `input_shape`
    (tuple of integers, does not include the sample axis),
    e.g. `input_shape=(128, 128, 3)` for 128x128 RGB pictures
    in `data_format="channels_last"`.

    # Arguments
        filters: Integer, the dimensionality of the output space
            (i.e. the number output of filters in the convolution).
        kernel_size: An integer or tuple/list of 2 integers, specifying the
            width and height of the 2D convolution window.
            Can be a single integer to specify the same value for
            all spatial dimensions.
        strides: An integer or tuple/list of 2 integers,
            specifying the strides of the convolution along the width and height.
            Can be a single integer to specify the same value for
            all spatial dimensions.
            Specifying any stride value != 1 is incompatible with specifying
            any `dilation_rate` value != 1.
        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".
        dilation_rate: an integer or tuple/list of 2 integers, specifying
            the dilation rate to use for dilated convolution.
            Can be a single integer to specify the same value for
            all spatial dimensions.
            Currently, specifying any `dilation_rate` value != 1 is
            incompatible with specifying any stride value != 1.
        activation: Activation function to use
            (see [activations](../activations.md)).
            If you don't specify anything, no activation is applied
            (ie. "linear" activation: `a(x) = x`).
        use_bias: Boolean, whether the layer uses a bias vector.
        kernel_initializer: Initializer for the `kernel` weights matrix
            (see [initializers](../initializers.md)).
        bias_initializer: Initializer for the bias vector
            (see [initializers](../initializers.md)).
        kernel_regularizer: Regularizer function applied to
            the `kernel` weights matrix
            (see [regularizer](../regularizers.md)).
        bias_regularizer: Regularizer function applied to the bias vector
            (see [regularizer](../regularizers.md)).
        activity_regularizer: Regularizer function applied to
            the output of the layer (its "activation").
            (see [regularizer](../regularizers.md)).
        kernel_constraint: Constraint function applied to the kernel matrix
            (see [constraints](../constraints.md)).
        bias_constraint: Constraint function applied to the bias vector
            (see [constraints](../constraints.md)).

    # Input shape
        4D tensor with shape:
        `(samples, channels, rows, cols)` if data_format='channels_first'
        or 4D tensor with shape:
        `(samples, rows, cols, channels)` if data_format='channels_last'.

    # Output shape
        4D tensor with shape:
        `(samples, filters, new_rows, new_cols)` if data_format='channels_first'
        or 4D tensor with shape:
        `(samples, new_rows, new_cols, filters)` if data_format='channels_last'.
        `rows` and `cols` values might have changed due to padding.
    i   R   R   R   c      "   K@  sŒ   t  t |  ƒ j d d d | d | d | d | d | d | d	 | d
 | d |	 d |
 d | d | d | d | d | |  t d d ƒ |  _ d  S(   NR   i   R   R   R   R    R"   R   R$   R%   R&   R'   R(   R)   R*   R+   R,   R   i   (   R   Rd   R   R   R-   (   R.   R   R   R   R    R"   R   R$   R%   R&   R'   R(   R)   R*   R+   R,   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   ¥  s&    c         C@  s&   t  t |  ƒ j ƒ  } | j d ƒ | S(   NR   (   R   Rd   RX   Rb   (   R.   R\   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   Ê  s    (   i   i   N(   i   i   (	   R^   R_   R`   R	   t   legacy_conv2d_supportR8   R;   R   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRd   T  s    Ot   Conv3Dc           B@  sP   e  Z d  Z e j d d d d	 d e d d d d d d d d „ ƒ Z d „  Z RS(
   s   3D convolution layer (e.g. spatial convolution over volumes).

    This layer creates a convolution kernel that is convolved
    with the layer input to produce a tensor of
    outputs. If `use_bias` is True,
    a bias vector is created and added to the outputs. Finally, if
    `activation` is not `None`, it is applied to the outputs as well.

    When using this layer as the first layer in a model,
    provide the keyword argument `input_shape`
    (tuple of integers, does not include the sample axis),
    e.g. `input_shape=(128, 128, 128, 3)` for 128x128x128 volumes
    with a single channel,
    in `data_format="channels_last"`.

    # Arguments
        filters: Integer, the dimensionality of the output space
            (i.e. the number output of filters in the convolution).
        kernel_size: An integer or tuple/list of 3 integers, specifying the
            width and height of the 3D convolution 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 convolution along each spatial dimension.
            Can be a single integer to specify the same value for
            all spatial dimensions.
            Specifying any stride value != 1 is incompatible with specifying
            any `dilation_rate` value != 1.
        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".
        dilation_rate: an integer or tuple/list of 3 integers, specifying
            the dilation rate to use for dilated convolution.
            Can be a single integer to specify the same value for
            all spatial dimensions.
            Currently, specifying any `dilation_rate` value != 1 is
            incompatible with specifying any stride value != 1.
        activation: Activation function to use
            (see [activations](../activations.md)).
            If you don't specify anything, no activation is applied
            (ie. "linear" activation: `a(x) = x`).
        use_bias: Boolean, whether the layer uses a bias vector.
        kernel_initializer: Initializer for the `kernel` weights matrix
            (see [initializers](../initializers.md)).
        bias_initializer: Initializer for the bias vector
            (see [initializers](../initializers.md)).
        kernel_regularizer: Regularizer function applied to
            the `kernel` weights matrix
            (see [regularizer](../regularizers.md)).
        bias_regularizer: Regularizer function applied to the bias vector
            (see [regularizer](../regularizers.md)).
        activity_regularizer: Regularizer function applied to
            the output of the layer (its "activation").
            (see [regularizer](../regularizers.md)).
        kernel_constraint: Constraint function applied to the kernel matrix
            (see [constraints](../constraints.md)).
        bias_constraint: Constraint function applied to the bias vector
            (see [constraints](../constraints.md)).

    # Input shape
        5D tensor with shape:
        `(samples, channels, conv_dim1, conv_dim2, conv_dim3)` if data_format='channels_first'
        or 5D tensor with shape:
        `(samples, conv_dim1, conv_dim2, conv_dim3, channels)` if data_format='channels_last'.

    # Output shape
        5D tensor with shape:
        `(samples, filters, new_conv_dim1, new_conv_dim2, new_conv_dim3)` if data_format='channels_first'
        or 5D tensor with shape:
        `(samples, new_conv_dim1, new_conv_dim2, new_conv_dim3, filters)` if data_format='channels_last'.
        `new_conv_dim1`, `new_conv_dim2` and `new_conv_dim3` values might have changed due to padding.
    i   R   R   R   c      "   K@  sŒ   t  t |  ƒ j d d d | d | d | d | d | d | d	 | d
 | d |	 d |
 d | d | d | d | d | |  t d d ƒ |  _ d  S(   NR   i   R   R   R   R    R"   R   R$   R%   R&   R'   R(   R)   R*   R+   R,   R   i   (   R   Rf   R   R   R-   (   R.   R   R   R   R    R"   R   R$   R%   R&   R'   R(   R)   R*   R+   R,   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   "  s&    c         C@  s&   t  t |  ƒ j ƒ  } | j d ƒ | S(   NR   (   R   Rf   RX   Rb   (   R.   R\   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   G  s    (   i   i   i   N(   i   i   i   (	   R^   R_   R`   R	   t   legacy_conv3d_supportR8   R;   R   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRf   Ð  s    Pt   Conv2DTransposec           B@  sh   e  Z d  Z e j d d d d e d d d d d d d d „ ƒ Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z RS(   sU  Transposed convolution layer (sometimes called Deconvolution).

    The need for transposed convolutions generally arises
    from the desire to use a transformation going in the opposite direction
    of a normal convolution, i.e., from something that has the shape of the
    output of some convolution to something that has the shape of its input
    while maintaining a connectivity pattern that is compatible with
    said convolution.

    When using this layer as the first layer in a model,
    provide the keyword argument `input_shape`
    (tuple of integers, does not include the sample axis),
    e.g. `input_shape=(128, 128, 3)` for 128x128 RGB pictures
    in `data_format="channels_last"`.

    # Arguments
        filters: Integer, the dimensionality of the output space
            (i.e. the number output of filters in the convolution).
        kernel_size: An integer or tuple/list of 2 integers, specifying the
            width and height of the 2D convolution window.
            Can be a single integer to specify the same value for
            all spatial dimensions.
        strides: An integer or tuple/list of 2 integers,
            specifying the strides of the convolution along the width and height.
            Can be a single integer to specify the same value for
            all spatial dimensions.
            Specifying any stride value != 1 is incompatible with specifying
            any `dilation_rate` value != 1.
        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".
        dilation_rate: an integer or tuple/list of 2 integers, specifying
            the dilation rate to use for dilated convolution.
            Can be a single integer to specify the same value for
            all spatial dimensions.
            Currently, specifying any `dilation_rate` value != 1 is
            incompatible with specifying any stride value != 1.
        activation: Activation function to use
            (see [activations](../activations.md)).
            If you don't specify anything, no activation is applied
            (ie. "linear" activation: `a(x) = x`).
        use_bias: Boolean, whether the layer uses a bias vector.
        kernel_initializer: Initializer for the `kernel` weights matrix
            (see [initializers](../initializers.md)).
        bias_initializer: Initializer for the bias vector
            (see [initializers](../initializers.md)).
        kernel_regularizer: Regularizer function applied to
            the `kernel` weights matrix
            (see [regularizer](../regularizers.md)).
        bias_regularizer: Regularizer function applied to the bias vector
            (see [regularizer](../regularizers.md)).
        activity_regularizer: Regularizer function applied to
            the output of the layer (its "activation").
            (see [regularizer](../regularizers.md)).
        kernel_constraint: Constraint function applied to the kernel matrix
            (see [constraints](../constraints.md)).
        bias_constraint: Constraint function applied to the bias vector
            (see [constraints](../constraints.md)).

    # Input shape
        4D tensor with shape:
        `(batch, channels, rows, cols)` if data_format='channels_first'
        or 4D tensor with shape:
        `(batch, rows, cols, channels)` if data_format='channels_last'.

    # Output shape
        4D tensor with shape:
        `(batch, filters, new_rows, new_cols)` if data_format='channels_first'
        or 4D tensor with shape:
        `(batch, new_rows, new_cols, filters)` if data_format='channels_last'.
        `rows` and `cols` values might have changed due to padding.

    # References
        - [A guide to convolution arithmetic for deep learning](https://arxiv.org/abs/1603.07285v1)
        - [Deconvolutional Networks](http://www.matthewzeiler.com/pubs/cvpr2010/cvpr2010.pdf)
    i   R   RJ   R   R   c         K@  sz   t  t |  ƒ j | | d | d | d | d | d | d | d |	 d |
 d	 | d
 | d | d | | t d d ƒ |  _ d  S(   NR   R    R"   R$   R%   R&   R'   R(   R)   R*   R+   R,   R   i   (   R   Rh   R   R   R-   (   R.   R   R   R   R    R"   R$   R%   R&   R'   R(   R)   R*   R+   R,   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   £  s"    c      
   C@  sB  t  | ƒ d k r8 t d t d ƒ d t | ƒ ƒ ‚ n  |  j d k rP d } n d } | | d  k ru t d ƒ ‚ n  | | } |  j |  j | f } |  j | d |  j d	 d
 d |  j	 d |  j
 ƒ|  _ |  j r|  j |  j f d |  j d	 d d |  j d |  j ƒ|  _ n	 d  |  _ t d d d i | | 6ƒ |  _ t |  _ d  S(   Ni   s   Inputs should have rank s   ; Received input shape:R0   i   iÿÿÿÿsD   The channel dimension of the inputs should be defined. Found `None`.R1   R2   R3   R4   R5   R6   R   R7   (   RN   R9   t   strR"   R8   R   R   R:   R&   R(   R+   R3   R%   R'   R)   R,   R6   R   R-   R;   R<   (   R.   R=   R>   R?   R@   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRA   Å  s2    	
						c      	   C@  sb  t  j | ƒ } | d } |  j d k r7 d \ } } n d	 \ } } | | | | } } |  j \ } }	 |  j \ }
 } t j | |
 | |  j ƒ } t j | | |	 |  j ƒ } |  j d k rÓ | |  j | | f } n | | | |  j f } t  j	 | |  j
 | |  j d |  j d |  j ƒ} |  j rBt  j | |  j d |  j ƒ} n  |  j d  k	 r^|  j | ƒ S| S(
   Ni    R0   i   i   i   R    R"   (   i   i   (   i   i   (   RB   t   shapeR"   R   R   R   t   deconv_lengthR    R   t   conv2d_transposeR3   R6   RF   R$   R8   (   R.   RG   R=   t
   batch_sizet   h_axist   w_axist   heightt   widtht   kernel_ht   kernel_wt   stride_ht   stride_wt
   out_heightt	   out_widtht   output_shapeRH   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   å  s@    
						c   
      C@  s·   t  | ƒ } |  j d k r- d \ } } } n d \ } } } |  j \ } } |  j \ } }	 |  j | | <t j | | | | |  j ƒ | | <t j | | |	 | |  j ƒ | | <t | ƒ S(   NR0   i   i   i   (   i   i   i   (   i   i   i   (	   RZ   R"   R   R   R   R   Rk   R    RQ   (
   R.   R=   Rx   t   c_axisRn   Ro   Rr   Rs   Rt   Ru   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV     s    c         C@  s&   t  t |  ƒ j ƒ  } | j d ƒ | S(   NR   (   R   Rh   RX   Rb   (   R.   R\   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX      s    (   i   i   N(   R^   R_   R`   R	   t   legacy_deconv2d_supportR8   R;   R   RA   RI   RV   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRh   M  s$   T	 	*	t   SeparableConv2Dc           B@  st   e  Z d  Z e j d
 d d d d e d d d d d d d d d d d „ ƒ Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(   sa  Depthwise separable 2D convolution.

    Separable convolutions consist in first performing
    a depthwise spatial convolution
    (which acts on each input channel separately)
    followed by a pointwise convolution which mixes together the resulting
    output channels. The `depth_multiplier` argument controls how many
    output channels are generated per input channel in the depthwise step.

    Intuitively, separable convolutions can be understood as
    a way to factorize a convolution kernel into two smaller kernels,
    or as an extreme version of an Inception block.

    # Arguments
        filters: Integer, the dimensionality of the output space
            (i.e. the number output of filters in the convolution).
        kernel_size: An integer or tuple/list of 2 integers, specifying the
            width and height of the 2D convolution window.
            Can be a single integer to specify the same value for
            all spatial dimensions.
        strides: An integer or tuple/list of 2 integers,
            specifying the strides of the convolution along the width and height.
            Can be a single integer to specify the same value for
            all spatial dimensions.
            Specifying any stride value != 1 is incompatible with specifying
            any `dilation_rate` value != 1.
        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".
        depth_multiplier: The number of depthwise convolution output channels
            for each input channel.
            The total number of depthwise convolution output
            channels will be equal to `filterss_in * depth_multiplier`.
        activation: Activation function to use
            (see [activations](../activations.md)).
            If you don't specify anything, no activation is applied
            (ie. "linear" activation: `a(x) = x`).
        use_bias: Boolean, whether the layer uses a bias vector.
        depthwise_initializer: Initializer for the depthwise kernel matrix
            (see [initializers](../initializers.md)).
        pointwise_initializer: Initializer for the pointwise kernel matrix
            (see [initializers](../initializers.md)).
        bias_initializer: Initializer for the bias vector
            (see [initializers](../initializers.md)).
        depthwise_regularizer: Regularizer function applied to
            the depthwise kernel matrix
            (see [regularizer](../regularizers.md)).
        pointwise_regularizer: Regularizer function applied to
            the depthwise kernel matrix
            (see [regularizer](../regularizers.md)).
        bias_regularizer: Regularizer function applied to the bias vector
            (see [regularizer](../regularizers.md)).
        activity_regularizer: Regularizer function applied to
            the output of the layer (its "activation").
            (see [regularizer](../regularizers.md)).
        depthwise_constraint: Constraint function applied to
            the depthwise kernel matrix
            (see [constraints](../constraints.md)).
        pointwise_constraint: Constraint function applied to
            the pointwise kernel matrix
            (see [constraints](../constraints.md)).
        bias_constraint: Constraint function applied to the bias vector
            (see [constraints](../constraints.md)).

    # Input shape
        4D tensor with shape:
        `(batch, channels, rows, cols)` if data_format='channels_first'
        or 4D tensor with shape:
        `(batch, rows, cols, channels)` if data_format='channels_last'.

    # Output shape
        4D tensor with shape:
        `(batch, filters, new_rows, new_cols)` if data_format='channels_first'
        or 4D tensor with shape:
        `(batch, new_rows, new_cols, filters)` if data_format='channels_last'.
        `rows` and `cols` values might have changed due to padding.
    i   R   R   R   c         K@  sË   t  t |  ƒ j d | d | d | d | d | d | d | d | d	 | d
 | |  
| |  _ t j |	 ƒ |  _ t j |
 ƒ |  _ t j | ƒ |  _	 t j | ƒ |  _
 t j | ƒ |  _ t j | ƒ |  _ d  S(   NR   R   R   R    R"   R$   R%   R)   R*   R,   (   R   R{   R   t   depth_multiplierR   R#   t   depthwise_initializert   pointwise_initializerR   t   depthwise_regularizert   pointwise_regularizerR   t   depthwise_constraintt   pointwise_constraint(   R.   R   R   R   R    R"   R|   R$   R%   R}   R~   R'   R   R€   R)   R*   R   R‚   R,   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   }  s&    	c      
   C@  s–  t  | ƒ d k  r* t d t | ƒ ƒ ‚ n  |  j d k rB d } n d } | | d  k rg t d ƒ ‚ n  t | | ƒ } |  j d |  j d | |  j f } d d |  j | |  j f } |  j	 | d |  j
 d	 d
 d |  j d |  j ƒ|  _ |  j	 | d |  j d	 d d |  j d |  j ƒ|  _ |  j ra|  j	 |  j f d |  j d	 d d |  j d |  j ƒ|  _ n	 d  |  _ t d d d i | | 6ƒ |  _ t |  _ d  S(   Ni   sE   Inputs to `SeparableConv2D` should have rank 4. Received input shape:R0   i   i   sY   The channel dimension of the inputs to `SeparableConv2D` should be defined. Found `None`.i    R1   R2   t   depthwise_kernelR4   R5   t   pointwise_kernelR6   R   R7   (   RN   R9   Ri   R"   R8   t   intR   R|   R   R:   R}   R   R   Rƒ   R~   R€   R‚   R„   R%   R'   R)   R,   R6   R   R-   R;   R<   (   R.   R=   R>   R?   t   depthwise_kernel_shapet   pointwise_kernel_shape(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRA   ¥  sJ    	


								c      
   C@  s€   t  j | |  j |  j d |  j d |  j d |  j ƒ} |  j r` t  j | |  j d |  j ƒ} n  |  j	 d  k	 r| |  j	 | ƒ S| S(   NR"   R   R    (   RB   t   separable_conv2dRƒ   R„   R"   R   R    R6   RF   R$   R8   (   R.   RG   RH   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   Ó  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 |  j | | f S|  j  d k rê | d | | |  j f Sd  S(   NR0   i   i   RJ   i   i    (   R"   R   RO   R   R    R   R   (   R.   R=   t   rowst   cols(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   æ  s     

c         C@  sÑ   t  t |  ƒ j ƒ  } | j d ƒ | j d ƒ | j d ƒ |  j | d <t j |  j ƒ | d <t j |  j ƒ | d <t	 j |  j
 ƒ | d <t	 j |  j ƒ | d <t j |  j ƒ | d	 <t j |  j ƒ | d
 <| S(   NR&   R(   R+   R|   R}   R~   R   R€   R   R‚   (   R   R{   RX   Rb   R|   R   RW   R}   R~   R   R   R€   R   R   R‚   (   R.   R\   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   ù  s    (   i   i   N(   R^   R_   R`   R	   t   legacy_separable_conv2d_supportR8   R;   R   RA   RI   RV   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR{   &  s,   U	.		t   UpSampling1Dc           B@  s>   e  Z d  Z e j d d „ ƒ Z d „  Z d „  Z d „  Z RS(   sF  Upsampling layer for 1D inputs.

    Repeats each temporal step `size` times along the time axis.

    # Arguments
        size: integer. Upsampling factor.

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

    # Output shape
        3D tensor with shape: `(batch, upsampled_steps, features)`.
    i   c         K@  s;   t  t |  ƒ j |   t | ƒ |  _ t d d ƒ |  _ d  S(   NR   i   (   R   RŒ   R   R…   t   sizeR   R-   (   R.   R   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR     s    c         C@  s<   | d d  k	 r! |  j | d n d  } | d | | d f S(   Ni   i    i   (   R8   R   (   R.   R=   R   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV     s    'c         C@  s   t  j | |  j d d ƒ} | S(   Nt   axisi   (   RB   t   repeat_elementsR   (   R.   RG   t   output(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   !  s    c         C@  sK   i |  j  d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR   (   R   R   RŒ   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   %  s    (	   R^   R_   R`   R	   t   legacy_upsampling1d_supportR   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRŒ     s   		t   UpSampling2Dc           B@  sA   e  Z d  Z e j d d d „ ƒ Z d „  Z d „  Z d „  Z	 RS(   s-  Upsampling layer for 2D inputs.

    Repeats the rows and columns of the data
    by size[0] and size[1] respectively.

    # Arguments
        size: int, or tuple of 2 integers.
            The upsampling factors for rows and columns.
        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
        4D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, rows, cols, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, rows, cols)`

    # Output shape
        4D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, upsampled_rows, upsampled_cols, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, upsampled_rows, upsampled_cols)`
    i   c         K@  sV   t  t |  ƒ j |   t j | ƒ |  _ t j | d d ƒ |  _ t d d ƒ |  _	 d  S(   Ni   R   R   i   (
   R   R’   R   R   R!   R"   R   R   R   R-   (   R.   R   R"   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   N  s    c         C@  sþ   |  j  d k r} | d d  k	 r4 |  j d | d n d  } | d d  k	 r_ |  j d | d n d  } | d | d | | f S|  j  d k rú | d d  k	 r± |  j d | d n d  } | d d  k	 rÜ |  j d | d n d  } | d | | | d f Sd  S(   NR0   i   i    i   i   RJ   (   R"   R8   R   (   R.   R=   Rp   Rq   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   U  s    ++++c         C@  s'   t  j | |  j d |  j d |  j ƒ S(   Ni    i   (   RB   t   resize_imagesR   R"   (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   e  s    c         C@  sU   i |  j  d 6|  j d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR   R"   (   R   R"   R   R’   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   i  s    (   i   i   N(
   R^   R_   R`   R	   t   legacy_upsampling2d_supportR8   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR’   +  s   !		t   UpSampling3Dc           B@  sA   e  Z d  Z e j d d d „ ƒ Z d „  Z d „  Z d „  Z	 RS(   s¦  Upsampling layer for 3D inputs.

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

    # Arguments
        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, 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
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, dim1, dim2, dim3, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, dim1, dim2, dim3)`

    # Output shape
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, upsampled_dim1, upsampled_dim2, upsampled_dim3, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, upsampled_dim1, upsampled_dim2, upsampled_dim3)`
    i   c         K@  sV   t  j | ƒ |  _ t  j | d d ƒ |  _ t d d ƒ |  _ t t |  ƒ j	 |   d  S(   Ni   R   R   i   (
   R   R!   R"   R   R   R   R-   R   R•   R   (   R.   R   R"   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   “  s    c         C@  sZ  |  j  d k r« | d d  k	 r4 |  j d | d n d  } | d d  k	 r_ |  j d | d n d  } | d d  k	 rŠ |  j d | d n d  } | d | d | | | f S|  j  d k rV| d d  k	 rß |  j d | d n d  } | d d  k	 r
|  j d | d n d  } | d d  k	 r5|  j d | d n d  } | d | | | | d f Sd  S(   NR0   i   i    i   i   i   RJ   (   R"   R8   R   (   R.   R=   t   dim1t   dim2t   dim3(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   š  s$    ++++++c         C@  s1   t  j | |  j d |  j d |  j d |  j ƒ S(   Ni    i   i   (   RB   t   resize_volumesR   R"   (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   ®  s    	c         C@  sU   i |  j  d 6|  j d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR   R"   (   R   R"   R   R•   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   ³  s    (   i   i   i   N(
   R^   R_   R`   R	   t   legacy_upsampling3d_supportR8   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR•   p  s   !		t   ZeroPadding1Dc           B@  s5   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z RS(   s_  Zero-padding layer for 1D input (e.g. temporal sequence).

    # Arguments
        padding: int, or tuple of int (length 2), or dictionary.
            - If int:
            How many zeros to add at the beginning and end of
            the padding dimension (axis 1).
            - If tuple of int (length 2):
            How many zeros to add at the beginning and at the end of
            the padding dimension (`(left_pad, right_pad)`).

    # Input shape
        3D tensor with shape `(batch, axis_to_pad, features)`

    # Output shape
        3D tensor with shape `(batch, padded_axis, features)`
    i   c         K@  sD   t  t |  ƒ j |   t j | d d ƒ |  _ t d d ƒ |  _ d  S(   Ni   R    R   i   (   R   R›   R   R   R   R    R   R-   (   R.   R    R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   Í  s    c         C@  sK   | d d  k	 r0 | d |  j d |  j d n d  } | d | | d f S(   Ni   i    i   (   R8   R    (   R.   R=   t   length(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   Ò  s    6c         C@  s   t  j | d |  j ƒS(   NR    (   RB   t   temporal_paddingR    (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   Ø  s    c         C@  sK   i |  j  d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR    (   R    R   R›   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   Û  s    (   R^   R_   R`   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR›   º  s
   		t   ZeroPadding2Dc           B@  sA   e  Z d  Z e j d d d „ ƒ Z d „  Z d „  Z d „  Z	 RS(   sí  Zero-padding layer for 2D input (e.g. picture).

    This layer can add rows and columns or zeros
    at the top, bottom, left and right side of an image tensor.

    # Arguments
        padding: int, or tuple of 2 ints, or tuple of 2 tuples of 2 ints.
            - If int: the same symmetric padding
                is applied to width and height.
            - If tuple of 2 ints:
                interpreted as two different
                symmetric padding values for height and width:
                `(symmetric_height_pad, symmetrc_width_pad)`.
            - If tuple of 2 tuples of 2 ints:
                interpreted as
                `((top_pad, bottom_pad), (left_pad, right_pad))`
        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
        4D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, rows, cols, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, rows, cols)`

    # Output shape
        4D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, padded_rows, padded_cols, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, padded_rows, padded_cols)`
    i   c         K@  sÿ   t  t |  ƒ j |   t j | ƒ |  _ t | t ƒ rU | | f | | f f |  _ n” t	 | d ƒ rÓ t
 | ƒ d k r t d t | ƒ ƒ ‚ n  t j | d d d ƒ } t j | d d d ƒ } | | f |  _ n t d t | ƒ ƒ ‚ t d	 d
 ƒ |  _ d  S(   Nt   __len__i   s+   `padding` should have two elements. Found: i    s   1st entry of paddingi   s   2nd entry of paddingsº   `padding` should be either an int, a tuple of 2 ints (symmetric_height_pad, symmetric_width_pad), or a tuple of 2 tuples of 2 ints ((top_pad, bottom_pad), (left_pad, right_pad)). Found: R   i   (   R   Rž   R   R   R!   R"   t
   isinstanceR…   R    t   hasattrRN   R9   Ri   R   R   R-   (   R.   R    R"   R/   t   height_paddingt   width_padding(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR     s     		c         C@  sJ  |  j  d k r£ | d d  k	 rG | d |  j d d |  j d d n d  } | d d  k	 r… | d |  j d d |  j d d n d  } | d | d | | f S|  j  d k rF| d d  k	 rê | d |  j d d |  j d d n d  } | d d  k	 r(| d |  j d d |  j d d n d  } | d | | | d f Sd  S(   NR0   i   i    i   i   RJ   (   R"   R8   R    (   R.   R=   R‰   RŠ   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   '  s    >>>>c         C@  s   t  j | d |  j d |  j ƒS(   NR    R"   (   RB   t   spatial_2d_paddingR    R"   (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   7  s    	c         C@  sU   i |  j  d 6|  j d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR    R"   (   R    R"   R   Rž   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   <  s    (   i   i   N(
   R^   R_   R`   R	   t   legacy_zeropadding2d_supportR8   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRž   á  s   )		t   ZeroPadding3Dc           B@  sA   e  Z d  Z e j d d d „ ƒ Z d „  Z d „  Z d „  Z	 RS(   s•  Zero-padding layer for 3D data (spatial or spatio-temporal).

    # Arguments
        padding: int, or tuple of 2 ints, or tuple of 2 tuples of 2 ints.
            - If int: the same symmetric padding
                is applied to width and height.
            - If tuple of 2 ints:
                interpreted as two different
                symmetric padding values for height and width:
                `(symmetric_dim1_pad, symmetric_dim2_pad, symmetric_dim3_pad)`.
            - If tuple of 2 tuples of 2 ints:
                interpreted as
                `((left_dim1_pad, right_dim1_pad), (left_dim2_pad, right_dim2_pad), (left_dim3_pad, right_dim3_pad))`
        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
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, first_axis_to_pad, second_axis_to_pad, third_axis_to_pad, depth)`
        - If `data_format` is `"channels_first"`:
            `(batch, depth, first_axis_to_pad, second_axis_to_pad, third_axis_to_pad)`

    # Output shape
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, first_padded_axis, second_padded_axis, third_axis_to_pad, depth)`
        - If `data_format` is `"channels_first"`:
            `(batch, depth, first_padded_axis, second_padded_axis, third_axis_to_pad)`
    i   c         K@  s$  t  t |  ƒ j |   t j | ƒ |  _ t | t ƒ r^ | | f | | f | | f f |  _ n° t	 | d ƒ rø t
 | ƒ d k r˜ t d t | ƒ ƒ ‚ n  t j | d d d ƒ } t j | d d d ƒ } t j | d d d	 ƒ } | | | f |  _ n t d
 t | ƒ ƒ ‚ t d d ƒ |  _ d  S(   NRŸ   i   s)   `padding` should have 3 elements. Found: i    i   s   1st entry of paddingi   s   2nd entry of paddings   3rd entry of paddings   `padding` should be either an int, a tuple of 3 ints (symmetric_dim1_pad, symmetric_dim2_pad, symmetric_dim3_pad), or a tuple of 3 tuples of 2 ints ((left_dim1_pad, right_dim1_pad), (left_dim2_pad, right_dim2_pad), (left_dim3_pad, right_dim2_pad)). Found: R   i   (   R   R¦   R   R   R!   R"   R    R…   R    R¡   RN   R9   Ri   R   R   R-   (   R.   R    R"   R/   t   dim1_paddingt   dim2_paddingt   dim3_padding(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   k  s$    '			c         C@  sŠ  |  j  d k rÃ | d d  k	 r< | d d |  j d d n d  } | d d  k	 ro | d d |  j d d n d  } | d d  k	 r¢ | d d |  j d d n d  } | d | d | | | f S|  j  d k r†| d d  k	 rÿ | d d |  j d d n d  } | d d  k	 r2| d d |  j d d n d  } | d d  k	 re| d d |  j d d n d  } | d | | | | d f Sd  S(   NR0   i   i    i   i   i   RJ   (   R"   R8   R    (   R.   R=   R–   R—   R˜   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   ‡  s$    333333c         C@  s   t  j | d |  j d |  j ƒS(   NR    R"   (   RB   t   spatial_3d_paddingR    R"   (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   ›  s    	c         C@  sU   i |  j  d 6|  j d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR    R"   (   R    R"   R   R¦   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX      s    (   i   i   i   N(
   R^   R_   R`   R	   t   legacy_zeropadding3d_supportR8   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR¦   C  s   &		t
   Cropping1Dc           B@  s5   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z RS(   s'  Cropping layer for 1D input (e.g. temporal sequence).

    It crops along the time dimension (axis 1).

    # Arguments
        cropping: int or tuple of int (length 2)
            How many units should be trimmed off at the beginning and end of
            the cropping dimension (axis 1).
            If a single int is provided,
            the same value will be used for both.

    # Input shape
        3D tensor with shape `(batch, axis_to_crop, features)`

    # Output shape
        3D tensor with shape `(batch, cropped_axis, features)`
    i   c         K@  sD   t  t |  ƒ j |   t j | d d ƒ |  _ t d d ƒ |  _ d  S(   Ni   t   croppingR   i   (   R   R¬   R   R   R   R­   R   R-   (   R.   R­   R/   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   º  s    c         C@  sN   | d d  k	 r3 | d |  j d |  j d } n d  } | d | | d f S(   Ni   i    i   (   R8   R­   (   R.   R=   Rœ   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   ¿  s    #c         C@  ss   |  j  d d k r= | d  d  … |  j  d d  … d  d  … f S| d  d  … |  j  d |  j  d … d  d  … f Sd  S(   Ni   i    (   R­   (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   È  s    *c         C@  sK   i |  j  d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR­   (   R­   R   R¬   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   Î  s    (   i   i   (   R^   R_   R`   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR¬   §  s
   			t
   Cropping2Dc           B@  sG   e  Z d  Z e j d d f d d „ ƒ Z d „  Z d „  Z d „  Z	 RS(	   s„  Cropping layer for 2D input (e.g. picture).

    It crops along spatial dimensions, i.e. width and height.

    # Arguments
        cropping: int, or tuple of 2 ints, or tuple of 2 tuples of 2 ints.
            - If int: the same symmetric cropping
                is applied to width and height.
            - If tuple of 2 ints:
                interpreted as two different
                symmetric cropping values for height and width:
                `(symmetric_height_crop, symmetrc_width_crop)`.
            - If tuple of 2 tuples of 2 ints:
                interpreted as
                `((top_crop, bottom_crop), (left_crop, right_crop))`
        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
        4D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, rows, cols, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, rows, cols)`

    # Output shape
        4D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, cropped_rows, cropped_cols, channels)`
        - If `data_format` is `"channels_first"`:
            `(batch, channels, cropped_rows, cropped_cols)`

    # Examples

    ```python
        # Crop the input 2D images or feature maps
        model = Sequential()
        model.add(Cropping2D(cropping=((2, 2), (4, 4)),
                             input_shape=(28, 28, 3)))
        # now model.output_shape == (None, 24, 20, 3)
        model.add(Conv2D(64, (3, 3), padding='same))
        model.add(Cropping2D(cropping=((2, 2), (2, 2))))
        # now model.output_shape == (None, 20, 16. 64)
    ```
    i    c         K@  sÿ   t  t |  ƒ j |   t j | ƒ |  _ t | t ƒ rU | | f | | f f |  _ n” t	 | d ƒ rÓ t
 | ƒ d k r t d t | ƒ ƒ ‚ n  t j | d d d ƒ } t j | d d d ƒ } | | f |  _ n t d t | ƒ ƒ ‚ t d	 d
 ƒ |  _ d  S(   NRŸ   i   s,   `cropping` should have two elements. Found: i    s   1st entry of croppingi   s   2nd entry of croppingsÁ   `cropping` should be either an int, a tuple of 2 ints (symmetric_height_crop, symmetric_width_crop), or a tuple of 2 tuples of 2 ints ((top_crop, bottom_crop), (left_crop, right_crop)). Found: R   i   (   R   R®   R   R   R!   R"   R    R…   R­   R¡   RN   R9   Ri   R   R   R-   (   R.   R­   R"   R/   t   height_croppingt   width_cropping(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR     s$    
	
	c         C@  s  |  j  d k r‹ | d | d | d rO | d |  j d d |  j d d n d  | d r„ | d |  j d d |  j d d n d  f S|  j  d k r| d | d rÓ | d |  j d d |  j d d n d  | d r| d |  j d d |  j d d n d  | d f Sd  S(   NR0   i    i   i   i   RJ   (   R"   R­   R8   (   R.   R=   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   &  s    5955c         C@  sR  |  j  d k r§|  j d d |  j d d k o< d k n rƒ | d  d  … d  d  … |  j d d d  … |  j d d d  … f S|  j d d d k rè | d  d  … d  d  … |  j d d d  … |  j d d |  j d d … f S|  j d d d k rM| d  d  … d  d  … |  j d d |  j d d … |  j d d d  … f S| d  d  … d  d  … |  j d d |  j d d … |  j d d |  j d d … f S|  j  d k rN|  j d d |  j d d k oãd k n r*| d  d  … |  j d d d  … |  j d d d  … d  d  … f S|  j d d d k r| d  d  … |  j d d d  … |  j d d |  j d d … d  d  … f S|  j d d d k rô| d  d  … |  j d d |  j d d … |  j d d d  … d  d  … f S| d  d  … |  j d d |  j d d … |  j d d |  j d d … d  d  … f Sd  S(   NR0   i    i   RJ   (   R"   R­   (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   2  s@    2%  %2". " c         C@  sU   i |  j  d 6|  j d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR­   R"   (   R­   R"   R   R®   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   \  s    (   i    i    (   i    i    N(
   R^   R_   R`   R	   t   legacy_cropping2d_supportR8   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR®   Ô  s   5			*t
   Cropping3Dc           B@  sJ   e  Z d  Z e j d d d f d	 d „ ƒ Z d „  Z d „  Z d „  Z	 RS(
   s®  Cropping layer for 3D data (e.g. spatial or spatio-temporal).

    # Arguments
        cropping: int, or tuple of 2 ints, or tuple of 2 tuples of 2 ints.
            - If int: the same symmetric cropping
                is applied to width and height.
            - If tuple of 2 ints:
                interpreted as two different
                symmetric cropping values for height and width:
                `(symmetric_dim1_crop, symmetric_dim2_crop, symmetric_dim3_crop)`.
            - If tuple of 2 tuples of 2 ints:
                interpreted as
                `((left_dim1_crop, right_dim1_crop), (left_dim2_crop, right_dim2_crop), (left_dim3_crop, right_dim3_crop))`
        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
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, first_axis_to_crop, second_axis_to_crop, third_axis_to_crop, depth)`
        - If `data_format` is `"channels_first"`:
            `(batch, depth, first_axis_to_crop, second_axis_to_crop, third_axis_to_crop)`

    # Output shape
        5D tensor with shape:
        - If `data_format` is `"channels_last"`:
            `(batch, first_cropped_axis, second_cropped_axis, third_cropped_axis, depth)`
        - If `data_format` is `"channels_first"`:
            `(batch, depth, first_cropped_axis, second_cropped_axis, third_cropped_axis)`
    i   c         K@  s$  t  t |  ƒ j |   t j | ƒ |  _ t | t ƒ r^ | | f | | f | | f f |  _ n° t	 | d ƒ rø t
 | ƒ d k r˜ t d t | ƒ ƒ ‚ n  t j | d d d ƒ } t j | d d d ƒ } t j | d d d	 ƒ } | | | f |  _ n t d
 t | ƒ ƒ ‚ t d d ƒ |  _ d  S(   NRŸ   i   s*   `cropping` should have 3 elements. Found: i    i   s   1st entry of croppingi   s   2nd entry of croppings   3rd entry of croppings
  `cropping` should be either an int, a tuple of 3 ints (symmetric_dim1_crop, symmetric_dim2_crop, symmetric_dim3_crop), or a tuple of 3 tuples of 2 ints ((left_dim1_crop, right_dim1_crop), (left_dim2_crop, right_dim2_crop), (left_dim3_crop, right_dim2_crop)). Found: R   i   (   R   R²   R   R   R!   R"   R    R…   R­   R¡   RN   R9   Ri   R   R   R-   (   R.   R­   R"   R/   t   dim1_croppingt   dim2_croppingt   dim3_cropping(    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR   ‹  s(    					c         C@  sÌ  |  j  d k rä | d d  k	 rG | d |  j d d |  j d d n d  } | d d  k	 r… | d |  j d d |  j d d n d  } | d d  k	 rÃ | d |  j d d |  j d d n d  } | d | d | | | f S|  j  d k rÈ| d d  k	 r+| d |  j d d |  j d d n d  } | d d  k	 ri| d |  j d d |  j d d n d  } | d d  k	 r§| d |  j d d |  j d d n d  } | d | | | | d f Sd  S(   NR0   i   i    i   i   i   RJ   (   R"   R8   R­   (   R.   R=   R–   R—   R˜   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRV   ª  s$    >>>>>>c         C@  sè  |  j  d k rr|  j d d |  j d d k oR |  j d d k oR d k n r­ | d  d  … d  d  … |  j d d d  … |  j d d d  … |  j d d d  … f S|  j d d |  j d d k oÚ d k n rA| d  d  … d  d  … |  j d d d  … |  j d d d  … |  j d d |  j d d … f S|  j d d |  j d d k ond k n rÕ| d  d  … d  d  … |  j d d |  j d d … |  j d d d  … |  j d d d  … f S|  j d d |  j d d k od k n ri| d  d  … d  d  … |  j d d d  … |  j d d |  j d d … |  j d d d  … f S|  j d d d k rî| d  d  … d  d  … |  j d d d  … |  j d d |  j d d … |  j d d |  j d d … f S|  j d d d k rs| d  d  … d  d  … |  j d d |  j d d … |  j d d d  … |  j d d |  j d d … f S|  j d d d k rø| d  d  … d  d  … |  j d d |  j d d … |  j d d |  j d d … |  j d d d  … f S| d  d  … d  d  … |  j d d |  j d d … |  j d d |  j d d … |  j d d |  j d d … f S|  j  d k rä|  j d d |  j d d k oÄ|  j d d k oÄd k n r| d  d  … |  j d d d  … |  j d d d  … |  j d d d  … d  d  … f S|  j d d |  j d d k oLd k n r³| d  d  … |  j d d d  … |  j d d d  … |  j d d |  j d d … d  d  … f S|  j d d |  j d d k oàd k n rG| d  d  … |  j d d |  j d d … |  j d d d  … |  j d d d  … d  d  … f S|  j d d |  j d d k otd k n rÛ| d  d  … |  j d d d  … |  j d d |  j d d … |  j d d d  … d  d  … f S|  j d d d k r`| d  d  … |  j d d d  … |  j d d |  j d d … |  j d d |  j d d … d  d  … f S|  j d d d k rå| d  d  … |  j d d |  j d d … |  j d d d  … |  j d d |  j d d … d  d  … f S|  j d d d k rj| d  d  … |  j d d |  j d d … |  j d d |  j d d … |  j d d d  … d  d  … f S| d  d  … |  j d d |  j d d … |  j d d |  j d d … |  j d d |  j d d … d  d  … f Sd  S(   NR0   i    i   i   RJ   (   R"   R­   (   R.   RG   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRI   ¾  s     H2%2 2  % %    %H"2.2 "2 " . .  "  c         C@  sU   i |  j  d 6|  j d 6} t t |  ƒ j ƒ  } t t | j ƒ  ƒ t | j ƒ  ƒ ƒ S(   NR­   R"   (   R­   R"   R   R²   RX   RY   RZ   R[   (   R.   R\   R]   (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyRX   !  s    (   i   i   (   i   i   (   i   i   N(
   R^   R_   R`   R	   t   legacy_cropping3d_supportR8   R   RV   RI   RX   (    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyR²   c  s   &		cN(2   t
   __future__R    t    R   RB   R   R   R   R   t   engineR   R   t   utilsR   t   legacyR	   t   poolingR
   R   R   R   R   R   t   legacy.layersR   R   R   Ra   Rd   Rf   Rh   R{   RŒ   R’   R•   R›   Rž   R¦   R¬   R®   R²   t   Convolution1Dt   Convolution2Dt   Convolution3Dt   SeparableConvolution2Dt   Convolution2DTransposet   Deconvolution2Dt   Deconv2Dt   AtrousConv1Dt   AtrousConv2D(    (    (    s9   /tmp/pip-build-isqEY4/keras/keras/layers/convolutional.pyt   <module>   sP   Ïk|}Ùâ#EJ'bd-Ç
