I want to create a custom min max pooling layer in tensorflow. What do i mean by that is as max pooling takes the maximum value in a matrix of size k I want to implement a layer which gets the min and max values in a matrix of size k and then concats them according to there index.
for eg:
sequence = [1,2,3,6,5,4]
i want to iterate over this tensor in chunks according to filter size say 3 and get the min and max values
1st chunk [1,2,3]
min value = 1
max value = 3
concat according to sequence [1,3]
2nd chunk [6,5,4]
min value = 4
max value = 6
concat according to sequence [6,4]
and then return whole downsampled sequence as [1,3,6,4]
thus converting
our original input [1,2,3,6,5,4]
to [1,3,6,4]
I tried to code a coustom layer in tensor flow using layer subclassing but got a lot of problems. Posted the question in stackoverflow but know one answered. I have provided a lot of details there you can use it as a reference. link = Custom - minmax pooling - Keras - Tensorflow
In the question the problem is with the while loop
I just want to implement a custom layer with min max pooling functionality as above in tensorflow using layer subclassing so it can be used to downsample the inputs by giving same importance to min values as max values.
Or any other efficient or simple way to implement this functionality in tensorflow.