小编Den*_*wan的帖子

用Theano实现LeCun局部对比度规范化

我正在尝试使用我发现的代码来实现LeCun局部对比度规范化,但结果不正确.代码在Python中并使用theano库.

def lecun_lcn(input, img_shape, kernel_shape, threshold=1e-4):
    """
    Yann LeCun's local contrast normalization
    Orginal code in Theano by: Guillaume Desjardins
    """
    input = input.reshape(input.shape[0], 1, img_shape[0], img_shape[1])
    X = T.matrix(dtype=theano.config.floatX)
    X = X.reshape(input.shape)

    filter_shape = (1, 1, kernel_shape, kernel_shape)
    filters = gaussian_filter(kernel_shape).reshape(filter_shape)

    convout = conv.conv2d(input=X,
                             filters=filters,
                             image_shape=(input.shape[0], 1, img_shape[0], img_shape[1]),
                             filter_shape=filter_shape,
                             border_mode='full')

    # For each pixel, remove mean of 9x9 neighborhood

    mid = int(np.floor(kernel_shape / 2.))
    centered_X = X - convout[:, :, mid:-mid, mid:-mid]
    # Scale down norm of …
Run Code Online (Sandbox Code Playgroud)

python machine-learning theano

3
推荐指数
1
解决办法
6190
查看次数

标签 统计

machine-learning ×1

python ×1

theano ×1