Keras: local (contrast) normalization

Created on 18 Aug 2015  路  5Comments  路  Source: keras-team/keras

As far as I know, LCN (local contrast normalization) is one of essential parts in systems that employ convolutional networks. I was wondering and have searched if it is implemented in Keras or if how I could implement it, but couldn't find any except one issue, #521, that Keras doesn't do it by default.

How do people do it then? This issue might be more suitable on google groups, but looks like here is more active. Also I'd like to know if it would be implemented in the future.

Thanks.

Most helpful comment

All 5 comments

LRN is already implemented. Please check convolutioal.py in layers.

If possible, submit a PR with the relavent documentation so others could find it easily. I didn't unfortunately.

Cool, it's so new that even the documents don't know it exists!
I just tried to add it after MaxPooling2D, like

from keras.layers import normalization
model.add(Convolution2D(num_stacks[0], 1, image_patch_sizes[0][0], image_patch_sizes[0][1], border_mode='same', activation = 'relu'))
    model.add(MaxPooling2D(poolsize=pool_sizes[0]))
    model.add(normalization.LRN2D())

, which resulted in an error.
Does anyone know how to use this?

The code above should work, please refer to this: https://github.com/fchollet/keras/pull/331#issuecomment-134149195

I couldn't find this code anymore in Keras, but according to @fchollet batch normalization is now preferable to using techniques like LCN:
https://groups.google.com/forum/#!topic/keras-users/8Ncd0dpuPNE

Was this page helpful?
0 / 5 - 0 ratings