# LCN¶

## Description¶

Info

Parent class: LRN

Derived classes: -

This module implements a local contrast normalization layer.

Local contrast normalization is a method used to normalize image contrast in a non-linear way. Instead of performing global normalization based on the range of values of the entire image, the LCN works with local portions of the image based on each pixel.

It is implemented by removing the average neighborhood value from a specific pixel and dividing by the change in pixel values.

This normalization technique is considered obsolete.

## Initializing¶

def __init__(self, N=5, alpha=1e-4, beta=0.75, K=2.0, includePad=True, name=None):


Parameters

Parameter Allowed types Description Default
N int Number of channels to sum up 5
alpha float Bias 1e-4
beta float Scale parameter 0.75
K float Scale parameter 2.0
includePad bool bool Whether to fill the values along the perimeter of the tensor True
name str Layer name None

Explanations

N - number of channels to sum up (for the transverse channel of LRN) or the length of the side of the square region to sum up (for the internal channel of LRN). The parameter value must be odd;

alpha - bias, a small positive number close to zero to avoid division by zero;

K - depth radius. Half width of the 1-D normalization window.

## Examples¶

Necessary imports.

>>> import numpy as np
>>> from PuzzleLib.Backend import gpuarray
>>> from PuzzleLib.Modules import LCN

>>> batchsize, maps, h, w = 1, 1, 5, 5
>>> data =  gpuarray.to_gpu(np.random.randn(batchsize, maps, h, w).astype(np.float32))
>>> lcn = LCN(N=5)
>>> lcn(data)