class
LazyInstanceNorm2d
extends
_LazyInstanceNormMixinLazyInstanceNorm2d(eps: float = 1e-05, momentum: float = 0.1, affine: bool = False, track_running_stats: bool = False, device: DeviceLike = None, dtype: DTypeLike = None)InstanceNorm2d with lazy num_features inference.
Identical to InstanceNorm2d except that num_features
is inferred from x.shape[1] on the first forward pass.
Parameters
epsfloat= 1e-05Numerical stability constant. Default:
1e-5.momentumfloat= 0.1EMA factor for optional running statistics. Default:
0.1.affinebool= FalseIf
True, lazily allocates per-channel scale and shift.
Default: False.track_running_statsbool= FalseIf
True, lazily allocates running mean/variance buffers.
Default: False.deviceDeviceLike= NoneDevice for lazily allocated tensors. Default:
None.dtypeDTypeLike= NoneData type for lazily allocated tensors. Default:
None.Notes
- Input: — same as
InstanceNorm2d.Cis inferred on the first forward pass. - Output: same shape as the input.
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> norm = nn.LazyInstanceNorm2d()
>>> x = lucid.randn(2, 64, 128, 128)
>>> out = norm(x) # num_features=64 inferred here
>>> out.shape
(2, 64, 128, 128)
Commonly used in generator networks where the channel dimension is
determined at runtime by a preceding convolution:
>>> norm_track = nn.LazyInstanceNorm2d(track_running_stats=True)
>>> out2 = norm_track(x)
>>> out2.shape
(2, 64, 128, 128)