How to make a convolution with maxout activation?

I want my activation function to select the maximum value generated by Nconvolution filters M x M. This layer converts the channel image Xinto a single channel.

How to do it?

I wrote first

classifier.add(Conv2D(3, (5, 5), activation='linear')
classifier.add(MaxPooling2D(pool_size=1, strides=1))

but then I thought that it does not return a 1-channel image, but returns 3 channels.

How to do it?

+4
source share
3 answers

So, to use this, you create Lambdaand maxfrom the backend:

from keras import backend as K

if K.image_data_format() == "channels_first":
    channels_axis = 1
else:
    channels_axis = 3

# To apply MaxOut:

classifier.add(Lambda(lambda x: K.max(x, axis=channels_axis, keepdims=True)))
+1
source

You can use keras.backend.maxand give it an argument axisto take the maximum along the right axis. Which one depends on your backend.

0

, , 1 , . .

classifier.add(Conv2D(1, (5,5),....))
-1
source

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


All Articles