I think the grouped convolutions, that have been merged in the development version this summer, should do what you need.
The speed may not be optimal, but it should be faster than using scan.

On 2017-10-19 12:48 PM, Peter O'Connor wrote:
Hi.  Did anyone figure this out?  I really need this op.  In my case I want to compute the per-channel cross correlation of two (512, 20, 20) feature maps.

Currently, I can't see any way to do this without using scan.  My current solution is:

class ChannelwiseCrossCorr(object):

     def __init__(self, border_mode='full', subsample=(1, 1)):
         self.border_mode = border_mode
         self.subsample = subsample

     def __call__(self, (x1, x2)):
         """
:param(x1, x2): are each (n_samples, n_channels, size_y, size_x) images
:return: A (n_samples, n_channels, size_y*2-1, size_x*2-1) image representing the channelwise cross-correlation between
each pair of images.
"""
from theano.tensor.signal.convimport conv2das sconv2d
         x1_flat = x1.reshape((x1.shape[0]*x1.shape[1], x2.shape[2], 
x2.shape[3]))
         x2_flat = x2.reshape((x2.shape[0]*x2.shape[1], x2.shape[2], 
x2.shape[3]))[:, ::-1, ::-1]
         map_flat, _ = theano.scan(partial(sconv2d, 
border_mode=self.border_mode, subsample=self.subsample), sequences=[x1_flat, 
x2_flat])
         conv_maps = map_flat.reshape((x1.shape[0], x1.shape[1], 
map_flat.shape[1], map_flat.shape[2]))
         return conv_maps


But it runs much slower than I expected, presumably due to the scan op.

--

---
You received this message because you are subscribed to the Google Groups "theano-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
Pascal Lamblin

--

--- You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to