Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make convolution with maxout activation?

Tags:

python

keras

I want my activation function select maximal value, generated by N filters of M x M convolution. This layer would convert X channel image to 1-channel one.

How to do that?

First I wrote

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

but then thought it doesn't return 1-channel image, but returns 3 channel.

How to do the job?

like image 592
Dims Avatar asked Nov 08 '22 19:11

Dims


1 Answers

So to apply this you shoud create a Lambda layer and max from 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)))
like image 133
Marcin Możejko Avatar answered Nov 15 '22 06:11

Marcin Możejko