
Xc           @` s   d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l j Z d d l	 m
 Z
 d d l Z d Z e j d  Z d d d d
 d	  Z d S(   sk   
Contains a wrapper function for tensor.nnet.ConvOp, which can be used to perform
generic 2D convolution.

i    (   t   absolute_importt   print_functiont   divisionN(   t   convs   restructuredtext ens   theano.tensor.signal.convt   validi   c         K` st  |  j  d k s t  | j  d k s* t  | r | r |  j  d k rR | d } n d } d t | d  } | j  d k r | d }	 n d }	 | d }
 n d \ }	 }
 d \ } } |  j  d k r |  j d } n d } | j  d k r | j d } n d } t j d t j | d g  |  j d  } t j |  | d d } t j d t j | d g  | j d  } t j | | d d } t	 j
 d | d	 | d d
 | d d | d |
 d |	 d | |  } | | |  } |  j  d k r4| j  d k r4t j j j rt j d d d n  t j | j d d j } n< |  j  d k sR| j  d k rpt j | j d d j } n  | S(   s  
    signal.conv.conv2d performs a basic 2D convolution of the input with the
    given filters. The input parameter can be a single 2D image or a 3D tensor,
    containing a set of images. Similarly, filters can be a single 2D filter or
    a 3D tensor, corresponding to a set of 2D filters.

    Shape parameters are optional and will result in faster execution.

    Parameters
    ----------
    input   : Symbolic theano tensor for images to be filtered.
              Dimensions: ([num_images], image height, image width)
    filters : Symbolic theano tensor for convolution filter(s).
              Dimensions: ([num_filters], filter height, filter width)
    border_mode: {'valid', 'full'}
        See scipy.signal.convolve2d.
    subsample
        Factor by which to subsample output.
    image_shape : tuple of length 2 or 3
        ([num_images,] image height, image width).
    filter_shape : tuple of length 2 or 3
        ([num_filters,] filter height, filter width).
    kwargs
        See theano.tensor.nnet.conv.conv2d.

    Returns
    -------
    symbolic 2D,3D or 4D tensor
        Tensor of filtered images, with shape
        ([number images,] [number filters,] image height, image width).

    i   i   i    i   it   ndimi   t   output_modet   dxt   dyt   imshpt   kshpt   nkernt   bsizes   theano.tensor.signal.conv2d() now outputs a 2d tensor when both inputs are 2d. To disable this warning, set the Theano flag warn.signal_conv2d_interface to Falset
   stacklevelt   outdim(   i   i   (   i   i   (   i   N(   NN(   NN(   R   t   AssertionErrort   tuplet   Nonet   shapet   tensort   joint   stackt   reshapeR   t   ConvOpt   theanot   configt   warnt   signal_conv2d_interfacet   warningst   flattent   T(   t   inputt   filterst   image_shapet   filter_shapet   border_modet	   subsamplet   kargsR   R	   R   R
   t	   sym_bsizet	   sym_nkernt   new_input_shapet   input4Dt   new_filter_shapet	   filters4Dt   opt   output(    (    s9   /tmp/pip-build-X4mzal/theano/theano/tensor/signal/conv.pyt   conv2d   sH    "++
(   i   i   (   t   __doc__t
   __future__R    R   R   R   R   t   theano.tensorR   t   theano.tensor.nnetR   t   loggingt   __docformat__t	   getLoggert   _loggerR   R.   (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/tensor/signal/conv.pyt   <module>   s   