Non-linear convolution in Teano

I am trying to create a “special” convolutional layer in Theano , where instead of linear filters confused with the image, I apply super- or involution (essentially dilution and erosion). How can I write such a convolution in an efficient way?

Given the tensor X , which should contain a set of vectors as inputs, its extension with the 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 correctly apply this operation to image sub-regions taking into account filling, tensor cutting, etc. for filters of any size. I also read in the documentation that using scan to implement convolutions is pretty inefficient. Any idea on how to do this?

+6
source share

Source: https://habr.com/ru/post/1015123/


All Articles