Skip to content

Feature Request: Local response normalization (LRN) #653

@keunhong

Description

@keunhong

PyTorch doesn't seem to have a module for LRN yet. This is needed for running models pre-trained with LRN layers (mainly AlexNet based models). I have a workaround using the legacy API

from torch import nn
from torch.autograd import Variable
from torch.legacy.nn import SpatialCrossMapLRN


class LRN(nn.Module):
    def __init__(self, size, alpha=1e-4, beta=0.75, k=1):
        super().__init__()
        self.lrn = SpatialCrossMapLRN(size, alpha, beta, k)

    def forward(self, x):
        self.lrn.clearState()
        return Variable(self.lrn.updateOutput(x.data))

but that doesn't seem to have a CUDA binding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions