DL0013 Instance Normalization

Can you explain what Instance Normalization is in the context of deep learning?

Answer

Instance Normalization (IN) normalizes each individual sample and each channel independently: for every (instance, channel) pair it subtracts the mean and divides by the standard deviation computed over that feature map’s spatial dimensions only. Because statistics never cross instance boundaries, IN is unaffected by mini-batch composition and works with batch size 1. This per-instance normalization removes sample-specific contrast and style, which is why IN became the standard in style transfer and image-generation models.

(1) Per-Instance, Per-Channel Statistics: Mean and variance are computed over the H \times W spatial positions of each channel of each sample separately, so no information leaks across the batch.
(2) Batch-Size Independent: Statistics do not depend on other samples, so IN behaves identically at training and test time and remains stable with small batches.
(3) Removes Instance-Specific Style: Normalizing each map’s contrast discards style-like appearance information while preserving content structure, which suits style transfer, GANs, and domain adaptation.

Side-by-side diagram of batch normalization sharing per-channel statistics across all instances versus instance normalization computing statistics within each instance-channel feature map.

Figure 1: BN pools statistics per channel across the whole batch (red dashed groups), while IN normalizes each (instance, channel) map alone (orange dashed boxes): the source of IN’s batch independence.

Mathematical Formulation:
\mu_{nc} = \frac{1}{HW} \sum_{h=1}^{H} \sum_{w=1}^{W} x_{nchw}
\sigma_{nc}^2 = \frac{1}{HW} \sum_{h=1}^{H} \sum_{w=1}^{W} (x_{nchw} - \mu_{nc})^2
\hat{x}_{nchw} = \frac{x_{nchw} - \mu_{nc}}{\sqrt{\sigma_{nc}^2 + \epsilon}}
y_{nchw} = \gamma_c\,\hat{x}_{nchw} + \beta_c

Where:

  • x_{nchw} is the input activation at batch index n, channel c, spatial position (h, w).
  • \mu_{nc} and \sigma_{nc}^2 are the mean and variance over the H \times W spatial extent of instance n, channel c.
  • \hat{x}_{nchw} is the normalized activation; \epsilon is a small constant for numerical stability.
  • \gamma_c and \beta_c are learnable per-channel scale and shift parameters; y_{nchw} is the output.

Contrast with Batch Normalization: BN computes per-channel statistics over the entire mini-batch (N \times H \times W), which couples a sample’s output to its batchmates and forces a switch to running averages at inference. IN’s per-sample statistics are identical in both phases, and discarding per-instance contrast is precisely what removes style from content images.

FeatureInstance Normalization (IN)Batch Normalization (BN)
Scope of statsPer instance, per channel (over H \times W)Per channel (over N \times H \times W)
Batch sizeIndependent; works with batch = 1Dependent; needs stable batch stats
Primary useStyle transfer, GANs, domain adaptationImage classification, general CNNs
EffectRemoves instance-specific style/contrastStabilizes training, speeds convergence
InferenceSame per-sample stats at test timeUses running stats from training

Bottom line: IN removes per-instance contrast (style); BN aligns feature scales across the batch. IN trades BN’s cross-sample regularization for batch independence and style removal.


Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *