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.
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.
It's actually in normalization: https://github.com/fchollet/keras/blob/97174dd298cf4b5be459e79b0181a124650d9148/keras/layers/normalization.py#L66
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
Most helpful comment
It's actually in normalization: https://github.com/fchollet/keras/blob/97174dd298cf4b5be459e79b0181a124650d9148/keras/layers/normalization.py#L66