10

I'm trying to make a "custom" convolutional layer in Theano, where instead of linear filters convoluted with an image, I'm applying sup- or inf- convolutions (essentially dilations and erosions). How would I go in writing such a convolution in an efficient way?

Given a tensor X intended to contain a set of vectors as inputs, its dilation with a filter W can be written as

dil, _ = theano.scan(fn = lambda x: T.max(W + x), sequences=[X])

The problem is that I don't know how to properly apply this operation to subregions of an image taking into account padding, tensor slicing etc. for filters of arbitrary size. I also read in the documentation that using scan to implement convolutions is pretty inefficient. Any idea on how to do this?

VHarisop
  • 2,816
  • 1
  • 14
  • 28
  • 1
    Looks like this should be a feature request. Theano lacks a general way to define a translation-invariant (could be nonlinear) filter. But if the filter radius is small, I think converting each ROI into a row vector, then perform filtering in a matrix fashion can be a hackish solution. – Kh40tiK Feb 21 '17 at 09:43
  • @Kh40tiK thanks for your reply! Would you happen to know if there is such a feature in Tensorflow or some other symbolic computation library? – VHarisop Feb 21 '17 at 15:06

0 Answers0