AI Logic

Normalization

Filter Response Normalization (FRN)

Updated:

The computation of FRN. Top left: the normalization range, pooling all positions of one channel of one sample. Top right: a graph of the TLU activation function, which moves ReLU's kink to a learned threshold τ. Bottom: the computation flow of the FRN layer (divide by the mean square → γ, β → TLU) and, for comparison, instance normalization with ReLU

What Is FRN?

Filter Response Normalization (FRN) is a method that normalizes one channel of one sample (a filter response) by dividing by the square root of its mean square without subtracting the mean, and pairs this with TLU, an activation function with a learned threshold. Singh and Krishnan (Google Research) proposed it in 2019. The paper calls this pair the "FRN layer", and it replaces both the normalization and the activation function that follow a convolutional layer.

Batch normalization loses a lot of accuracy with small mini-batches. Batch Renormalization and Group Normalization were proposed to ease this, but according to the paper, the former still loses accuracy with small batches, and the latter falls short of batch normalization with large batches and also requires the number of channels to be a multiple of the number of groups. FRN normalizes without using other samples or other channels, so it is unaffected by batch size.

In the paper's experiments (ResnetV2-50, ImageNet), even with 32 images per GPU, the setting most favorable to batch normalization, top-1 accuracy was 77.21% for the FRN layer versus 76.21% for batch normalization. Even with just 1 image per GPU, the FRN layer kept 77.36%.

Computation Steps

Let the output of a convolutional layer be "batch BB × height HH × width WW × channels CC". With the N=H×WN = H \times W values of channel cc of sample bb written as x=(x1,…,xN)x = (x_1, \dots, x_N), the FRN layer computes the following in order (Section 3.1 of the paper, Eqs. (1)–(3)).

  1. Compute the mean square ν2\nu^2. Not subtracting the mean is the key difference from other normalization methods. ν2=1N∑i=1Nxi2\nu^2 = \frac{1}{N} \sum_{i=1}^{N} x_i^2
  2. Divide by the square root of ν2\nu^2. ϵ\epsilon is a small positive constant that prevents division by zero. x^i=xiν2+ϵ\hat{x}_i = \frac{x_i}{\sqrt{\nu^2 + \epsilon}}
  3. Apply the learned scale and shift. γ\gamma and β\beta are per-channel parameters. yi=γx^i+βy_i = \gamma \hat{x}_i + \beta
  4. Pass through the TLU (Thresholded Linear Unit) activation function. τ\tau is a threshold learned per channel. zi=max⁡(yi,τ)z_i = \max(y_i, \tau)

The normalization range is the entire spatial extent of one channel of one sample, the same as Instance Normalization. The difference is that instance normalization subtracts the mean μ\mu and divides by the variance, xi−μσ2+ϵ\frac{x_i - \mu}{\sqrt{\sigma^2 + \epsilon}}, while FRN does not subtract the mean and divides by the mean square. RMSNorm also divides by the root mean square without subtracting the mean, but RMSNorm pools all dimensions of one token, whereas FRN pools the spatial positions of one channel.

TLU can be written as max⁡(y,τ)=max⁡(y−τ,0)+τ=ReLU(y−τ)+τ\max(y, \tau) = \max(y - \tau, 0) + \tau = \mathrm{ReLU}(y - \tau) + \tau. It is ReLU with its kink moved from the origin to (τ,τ)(\tau, \tau). The top right of the figure at the top of the article shows this graph.

Learn ε for fully connected layers and 1×1 feature maps

When N=1N = 1 (the output of a fully connected layer, or a 1×1 feature map), a small ϵ\epsilon makes x^=x/x2+ϵ\hat{x} = x / \sqrt{x^2 + \epsilon} nearly a sign function (±1\pm 1), so almost no gradient flows. A large ϵ\epsilon gives a smooth shape like Softsign (Figure 3 of the paper). For models containing such layers (the auxiliary output of Inception V3 and the fully connected layers of VGG-A), the paper therefore sets ϵ=10−6+∣ϵl∣\epsilon = 10^{-6} + |\epsilon_l| and learns ϵl\epsilon_l (initialized to 10−410^{-4}). For other models, it is fixed at ϵ=10−6\epsilon = 10^{-6} (Section 3.3 of the paper).

Why Not Subtract the Mean, and Why Use TLU?

Batch-independent normalization has no reason to subtract the mean

The paper argues that subtracting the mean is inherited from batch normalization, which aimed to align the distribution of the whole dataset, and has no justification in methods that normalize within a single sample (Section 3.4 of the paper). Moreover, subtracting the mean within one channel, as instance normalization does, pushes the output toward 0 as the feature map shrinks, and when N=1N = 1 the output is always 0. Layer Normalization and Group Normalization avoid this by pooling channels, but normalizing channels together creates unnecessary coupling in the filter updates.

FRN therefore aligns only the magnitude of each channel, without subtracting the mean. This removes the scaling caused by the magnitude of the filter weights, so every filter carries the same weight in the final model.

TLU absorbs the offset left by not subtracting the mean

Without mean subtraction, the normalized values can be biased away from 0. Passing them through ReLU as is can cause problems such as most values becoming 0 and learning stalling (dying ReLU). TLU adapts to this bias by learning the kink position τ\tau. The paper notes that TLU has the same form as adding biases before and after ReLU, yet experiments did not give the same results when those biases were absorbed into the biases of the neighboring layers, suggesting that the TLU form may be easier to optimize.

As an analogy, instance normalization "sets each channel's values to mean 0 and spread 1", while FRN "leaves the mean as is, sets only the overall magnitude to 1, and learns the threshold (τ) at which values start passing through".

Properties of the gradient

The paper shows that the gradient through the FRN layer takes the following form (Eq. (7)).

∂f∂x=1ν2+ϵ(I−x^x^⊤N)∂f∂x^\frac{\partial f}{\partial x} = \frac{1}{\sqrt{\nu^2 + \epsilon}} \left( I - \frac{\hat{x}\hat{x}^\top}{N} \right) \frac{\partial f}{\partial \hat{x}}

The term in parentheses is a projection that removes the component in the direction of x^\hat{x}; with ϵ=0\epsilon = 0, the gradient is orthogonal to xx. This property, also known from the Weight Normalization paper, reduces gradient variance and aids optimization. In addition, the gradient for the region yi<τy_i < \tau, which ReLU would discard, is used to update τ\tau.

Experimental Results

Large batches: top-1 accuracy on the ImageNet validation set was compared with 8 GPUs and 32 images per GPU (256 in total) (Table 1 of the paper). This is the setting most favorable to batch normalization.

NormalizationResnetV2-50Inception V3
Batch normalization76.21%78.24%
Batch Renormalization75.85%78.19%
Group Normalization75.67%78.14%
Layer Normalization72.75%76.75%
Instance Normalization71.63%73.93%
FRN layer77.21%78.95%

Small batches: top-1 accuracy of ResnetV2-50 for different numbers of images per GPU (Table 2 of the paper).

Images per GPU32168421
Batch normalization76.21%75.55%74.04%71.96%65.09%1.58%
Batch Renormalization75.85%75.96%75.59%74.18%70.75%37.55%
Group Normalization75.67%75.77%76.14%76.02%76.20%75.93%
FRN layer77.21%77.10%77.16%77.18%77.33%77.36%

The FRN layer stayed in the 77% range at every batch size, beating the second-best method by 1.0–1.5 points.

Both FRN and TLU are needed: in an ablation over combinations (Table 3 of the paper, ResnetV2-50), instance normalization + ReLU gave 71.63%, FRN + ReLU 75.24%, and FRN + TLU 77.21%. Normalization without mean subtraction added 3.61 points, and TLU a further 1.97 points. On the other hand, replacing ReLU with TLU in batch normalization barely changed accuracy, from 76.21% to 76.03%. TLU is effective only in combination with normalization that does not subtract the mean.

Object detection: AP on COCO object detection (RetinaNet, ResnetV1-101 with FPN, 1024×1024 input, no pretraining) is as follows (Table 6 of the paper).

Images per GPU842
Batch normalization38.737.930.2
Group Normalization39.339.038.7
FRN layer39.639.539.1

Models with fully connected layers: on VGG-A (two fully connected layers) as well, with a learning rate of 0.1, FRN reached 71.66%, beating Group Normalization (69.94%) and batch normalization (62.61%). The model without normalization diverged (Table 4 of the paper).

Practical Considerations

Learning-rate warmup may be required. Because FRN does not subtract the mean, some models are sensitive to the initial learning rate. With a high learning rate, values grow large in the first few steps (especially in VGG-A, which uses a lot of max pooling), the normalized values saturate, and training stalls. In the paper, without warmup, accuracy dropped for Inception V3 and VGG-A failed to train at all. Other normalization methods were hardly affected.

For fully connected layers and 1×1 feature maps, make ϵ\epsilon a learnable parameter. With a small fixed ϵ\epsilon, normalization becomes nearly a sign function and gradients do not flow.

Also keep the following points in mind.

  • Replace normalization and the activation function together. The FRN layer stands in for "normalization + ReLU". Adding only FRN and keeping ReLU loses the benefit of TLU (75.24% on ResnetV2-50).
  • Continuous learning-rate decay suits it better than step decay. In the paper, step decay was not optimal for FRN, and cosine decay (without restarts) gave better results for every method.
  • PyTorch has no built-in layer. It takes only a few lines, as in the code example below. Because it keeps no running averages, the computation is the same under model.train() and model.eval().
  • Evaluation focuses on vision tasks. The paper's experiments cover image classification and object detection; evaluation in other fields where normalization is used, such as natural language processing, is left to future work.

Comparison with Other Normalization Methods

AspectFRN layerBatch normalizationGroup NormalizationInstance Normalization
Normalization rangeOne sample, spatial extent of one channelOne channel, batch × spaceOne sample, group of channels × spaceOne sample, spatial extent of one channel
Subtracts the mean?No (divides by the mean square)YesYesYes
Activation functionTLU (used as a pair)Chosen separately (ReLU, etc.)Chosen separatelyChosen separately
Effect of batch sizeNot affectedAffected (worse when small)Not affectedNot affected
ImageNet (ResnetV2-50, 32 images)77.21%76.21%75.67%71.63%
Structural constraints and caveatsWarmup, learning εNeeds large batchesNumber of channels must be divisible by the number of groupsLow accuracy on recognition tasks

Rough guidelines for choosing:

  • CNNs that can use sufficiently large batches: batch normalization is the standard. Under the paper's conditions the FRN layer was more accurate, but training settings such as warmup need to be revisited.
  • CNNs where batches become small, such as object detection: Group Normalization or the FRN layer. In the paper's comparison, the FRN layer came out ahead.
  • You want to choose the number of channels freely (not as a multiple of the number of groups): the FRN layer.
  • Transformers and RNNs: Layer Normalization or RMSNorm.

PyTorch example

Show code
python
import torch
import torch.nn as nn

class FRN(nn.Module):
    """Eqs. (1)-(3) of the paper: Filter Response Normalization + TLU (not built into PyTorch)"""
    def __init__(self, num_channels, eps=1e-6, learnable_eps=False):
        super().__init__()
        shape = (1, num_channels, 1, 1)                      # γ, β, τ are per channel
        self.gamma = nn.Parameter(torch.ones(shape))
        self.beta = nn.Parameter(torch.zeros(shape))
        self.tau = nn.Parameter(torch.zeros(shape))
        self.eps = eps
        # For fully connected layers or 1×1 feature maps, learn ε: ε = 1e-6 + |ε_l| (ε_l initialized to 1e-4)
        self.eps_l = nn.Parameter(torch.tensor(1e-4)) if learnable_eps else None

    def forward(self, x):                                    # x: [N, C, H, W]
        nu2 = x.pow(2).mean(dim=(2, 3), keepdim=True)        # 1. per-channel mean of squares (no mean subtraction)
        eps = self.eps + self.eps_l.abs() if self.eps_l is not None else self.eps
        x = x * torch.rsqrt(nu2 + eps)                       # 2. divide by the root mean square
        y = self.gamma * x + self.beta                       # 3. scale and shift
        return torch.max(y, self.tau)                        # 4. TLU:max(y, τ)

# Replace "conv -> batch norm -> ReLU" with "conv -> FRN layer"
block = nn.Sequential(
    nn.Conv2d(3, 64, kernel_size=3, padding=1),
    FRN(64),
)

x = torch.randn(1, 3, 32, 32)          # even a single image is unaffected by other samples
block.train(); y_train = block(x)
block.eval();  y_eval = block(x)
print(torch.allclose(y_train, y_eval))  # True (no running averages)

FAQ

Q. Can FRN be added alone while keeping ReLU as the activation function?
A.

Not recommended. In the paper's ResnetV2-50 experiments, the FRN + ReLU pair reached 75.24%, lower than batch normalization (76.21%). Only when combined with TLU does it rise to 77.21%. Normalization without mean subtraction can leave values biased away from 0, and TLU, with its learned threshold, absorbs that bias.

Q. How do RMSNorm and FRN differ?
A.

Both divide by the root mean square without subtracting the mean. They differ in the range of values pooled and where they are used. RMSNorm is used in Transformers and normalizes all dimensions of one token together. FRN is used in CNNs, normalizes all spatial positions of one channel of one image together, and is paired with the TLU activation function.

Q. What should be checked when training does not progress?
A.

First check whether learning-rate warmup is in place. In the paper, VGG-A, which uses a lot of max pooling, failed to train at all without warmup. Next, if FRN is placed after fully connected layers or 1×1 feature maps, check whether ε is a learnable parameter.

References

  1. S. Singh and S. Krishnan, "Filter Response Normalization Layer: Eliminating Batch Dependence in the Training of Deep Neural Networks," CVPR, 2020.
  2. S. Ioffe and C. Szegedy, "Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift," ICML, 2015.
  3. Y. Wu and K. He, "Group Normalization," ECCV, 2018.
  4. D. Ulyanov, A. Vedaldi, and V. Lempitsky, "Instance Normalization: The Missing Ingredient for Fast Stylization," arXiv, 2016.