class torch.nn.InstanceNorm1d(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = False, track_running_stats: bool = False)
Applies Instance Normalization over a 3D input (a mini-batch of 1D inputs with optional additional channel dimension) as described in the paper Instance Normalization: The Missing Ingredient for Fast Stylization.
The mean and standard-deviation are calculated per-dimension separately for each object in a mini-batch. and are learnable parameter vectors of size
C is the input size) if
True. The standard-deviation is calculated via the biased estimator, equivalent to
By default, this layer uses instance statistics computed from input data in both training and evaluation modes.
track_running_stats is set to
True, during training this layer keeps running estimates of its computed mean and variance, which are then used for normalization during evaluation. The running estimates are kept with a default
momentum of 0.1.
momentum argument is different from one used in optimizer classes and the conventional notion of momentum. Mathematically, the update rule for running statistics here is , where is the estimated statistic and is the new observed value.
LayerNorm are very similar, but have some subtle differences.
InstanceNorm1d is applied on each channel of channeled data like multidimensional time series, but
LayerNorm is usually applied on entire sample and often in NLP tasks. Additionally,
LayerNorm applies elementwise affine transform, while
InstanceNorm1d usually don’t apply affine transform.
True, this module has learnable affine parameters, initialized the same way as done for batch normalization. Default:
True, this module tracks the running mean and variance, and when set to
False, this module does not track such statistics and always uses batch statistics in both training and eval modes. Default:
>>> # Without Learnable Parameters >>> m = nn.InstanceNorm1d(100) >>> # With Learnable Parameters >>> m = nn.InstanceNorm1d(100, affine=True) >>> input = torch.randn(20, 100, 40) >>> output = m(input)
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.