class
InstanceNorm3d
extends
_InstanceNormBaseInstanceNorm3d(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = False, track_running_stats: bool = False, device: DeviceLike = None, dtype: DTypeLike = None)Instance normalization for 5-D input (N, C, D, H, W).
Normalises each (n, c) slice over the three spatial dimensions
independently:
where and are computed over the voxels of sample , channel .
Applicable to volumetric data such as 3-D medical images or spatio-temporal video features, where per-sample independence is important and batch-level statistics are undesirable.
Parameters
num_featuresintNumber of feature channels .
epsfloat= 1e-05Numerical stability constant. Default:
1e-5.momentumfloat= 0.1EMA factor for optional running stats. Default:
0.1.affinebool= FalseIf
True, learns per-channel and .
Default: False.track_running_statsbool= FalseIf
True, maintains running mean/variance buffers.
Default: False.deviceDeviceLike= NoneDevice for parameters/buffers. Default:
None.dtypeDTypeLike= NoneData type for parameters/buffers. Default:
None.Attributes
weightParameter or NonePer-channel scale , shape
(num_features,).
None when affine=False.biasParameter or NonePer-channel shift , shape
(num_features,).
None when affine=False.running_meanTensor or NoneRunning mean per channel, shape
(num_features,).
None when track_running_stats=False.running_varTensor or NoneRunning variance per channel, shape
(num_features,).
None when track_running_stats=False.Notes
- Input:
- Output: — same shape.
Examples
3-D volumetric feature maps:
>>> import lucid
>>> import lucid.nn as nn
>>> norm = nn.InstanceNorm3d(16)
>>> x = lucid.randn(2, 16, 8, 32, 32) # (N, C, D, H, W)
>>> out = norm(x)
>>> out.shape
(2, 16, 8, 32, 32)
Enable running stats for a test-time normalization baseline:
>>> norm_track = nn.InstanceNorm3d(16, track_running_stats=True)
>>> out2 = norm_track(x)
>>> out2.shape
(2, 16, 8, 32, 32)