def conv2d(input, filters, image_shape=None, filter_shape=None, border_mode='valid', subsample=(1, 1), **kargs):
 if (image_shape is not None):
  image_shape = list(image_shape)
  for i in xrange(len(image_shape)):
   if (image_shape[i] is not None):
    try:
     image_shape[i] = get_scalar_constant_value(as_tensor_variable(image_shape[i]))
    except NotScalarConstantError:
     raise NotScalarConstantError(('The convolution need that the shape information are constant values. We got %s for the image_shape parameter' % image_shape[i]))
    assert (image_shape[i].dtype in theano.tensor.discrete_dtypes)
    image_shape[i] = int(image_shape[i])
 if (filter_shape is not None):
  filter_shape = list(filter_shape)
  for i in xrange(len(filter_shape)):
   if (filter_shape[i] is not None):
    try:
     filter_shape[i] = get_scalar_constant_value(as_tensor_variable(filter_shape[i]))
    except NotScalarConstantError:
     raise NotScalarConstantError(('The convolution need that the shape information are constant values. We got %s for the filter_shape parameter' % filter_shape[i]))
    assert (filter_shape[i].dtype in theano.tensor.discrete_dtypes)
    filter_shape[i] = int(filter_shape[i])
 if (image_shape and filter_shape):
  try:
   if ((image_shape[1] is not None) and (filter_shape[1] is not None)):
    assert (image_shape[1] == filter_shape[1])
  except Exception:
   print('image ', image_shape, ' filters ', filter_shape)
   raise
 if (filter_shape is not None):
  nkern = filter_shape[0]
  kshp = filter_shape[2:]
 else:
  (nkern, kshp) = (None, None)
 if (image_shape is not None):
  bsize = image_shape[0]
  imshp = image_shape[1:]
 else:
  (bsize, imshp) = (None, None)
 op = ConvOp(output_mode=border_mode, dx=subsample[0], dy=subsample[1], imshp=imshp, kshp=kshp, nkern=nkern, bsize=bsize, **kargs)
 return op(input, filters)

def conv2d ( input , filters , image_shape = None , filter_shape = None , border_mode = 'valid' , subsample = ( 1 , 1 ) , ** kargs ) : if ( image_shape is not None ) : image_shape = list ( image_shape ) for i in xrange ( len ( image_shape ) ) : if ( image_shape [ i ] is not None ) : try : image_shape [ i ] = get_scalar_constant_value ( as_tensor_variable ( image_shape [ i ] ) ) except NotScalarConstantError : raise NotScalarConstantError ( ( 'The convolution need that the shape information are constant values. We got %s for the image_shape parameter' % image_shape [ i ] ) ) assert ( image_shape [ i ] . dtype in theano . tensor . discrete_dtypes ) image_shape [ i ] = int ( image_shape [ i ] ) if ( filter_shape is not None ) : filter_shape = list ( filter_shape ) for i in xrange ( len ( filter_shape ) ) : if ( filter_shape [ i ] is not None ) : try : filter_shape [ i ] = get_scalar_constant_value ( as_tensor_variable ( filter_shape [ i ] ) ) except NotScalarConstantError : raise NotScalarConstantError ( ( 'The convolution need that the shape information are constant values. We got %s for the filter_shape parameter' % filter_shape [ i ] ) ) assert ( filter_shape [ i ] . dtype in theano . tensor . discrete_dtypes ) filter_shape [ i ] = int ( filter_shape [ i ] ) if ( image_shape and filter_shape ) : try : if ( ( image_shape [ 1 ] is not None ) and ( filter_shape [ 1 ] is not None ) ) : assert ( image_shape [ 1 ] == filter_shape [ 1 ] ) except Exception : print ( 'image ' , image_shape , ' filters ' , filter_shape ) raise if ( filter_shape is not None ) : nkern = filter_shape [ 0 ] kshp = filter_shape [ 2 : ] else : ( nkern , kshp ) = ( None , None ) if ( image_shape is not None ) : bsize = image_shape [ 0 ] imshp = image_shape [ 1 : ] else : ( bsize , imshp ) = ( None , None ) op = ConvOp ( output_mode = border_mode , dx = subsample [ 0 ] , dy = subsample [ 1 ] , imshp = imshp , kshp = kshp , nkern = nkern , bsize = bsize , ** kargs ) return op ( input , filters )
this function will build the symbolic graph for convolving a mini-batch of a stack of 2d inputs with a set of 2d filters .