lllyasviel/Fooocus · error · ValueError
Wrong activation value in EqualLinear: {activation}Supported
Error message
Wrong activation value in EqualLinear: {activation}Supported ones are: ['fused_lrelu', None]. What it means
EqualLinear is the equalized-learning-rate linear layer used by Fooocus's face-restoration StyleGAN2 architecture (ldm_patched/pfn/architecture/face/stylegan2_arch.py). Its constructor only accepts activation=None or 'fused_lrelu'; any other string raises ValueError immediately at module construction. This is a hard configuration check, not a runtime data error.
Source
Thrown at ldm_patched/pfn/architecture/face/stylegan2_arch.py:168
Supported: 'fused_lrelu', None. Default: None.
"""
def __init__(
self,
in_channels,
out_channels,
bias=True,
bias_init_val=0,
lr_mul=1,
activation=None,
):
super(EqualLinear, self).__init__()
self.in_channels = in_channels
self.out_channels = out_channels
self.lr_mul = lr_mul
self.activation = activation
if self.activation not in ["fused_lrelu", None]:
raise ValueError(
f"Wrong activation value in EqualLinear: {activation}"
"Supported ones are: ['fused_lrelu', None]."
)
self.scale = (1 / math.sqrt(in_channels)) * lr_mul
self.weight = nn.Parameter(torch.randn(out_channels, in_channels).div_(lr_mul))
if bias:
self.bias = nn.Parameter(torch.zeros(out_channels).fill_(bias_init_val))
else:
self.register_parameter("bias", None)
def forward(self, x):
if self.bias is None:
bias = None
else:
bias = self.bias * self.lr_mul
if self.activation == "fused_lrelu":
out = F.linear(x, self.weight * self.scale)View on GitHub (pinned to ae05379cc9)
Solutions
- Set activation=None (plain linear, activation applied externally) or activation='fused_lrelu' in the EqualLinear call.
- If you need a different activation, keep EqualLinear(activation=None) and apply nn.LeakyReLU/etc. on the output tensor in the parent module instead.
- If the value comes from a checkpoint/config dict, inspect it (print the activation field) and remap legacy names to the supported set before construction.
Example fix
// before EqualLinear(512, 512, activation='lrelu') // after EqualLinear(512, 512, activation=None) # then apply F.leaky_relu(out) yourself
Defensive patterns
Strategy: validation
Validate before calling
valid = {None, 'fused_lrelu'}
assert activation in valid, f'activation must be one of {valid}, got {activation!r}' Type guard
def is_equal_linear_activation(v) -> bool:
return v is None or (isinstance(v, str) and v == 'fused_lrelu') Prevention
- Keep a single module-level constant EQUAL_LINEAR_ACTIVATIONS = ('fused_lrelu', None) and validate configs against it.
- Apply custom activations in the parent forward(), never inside EqualLinear.
When it happens
Trigger: Instantiating EqualLinear(in_channels, out_channels, activation='relu') (or 'lrelu', 'gelu', etc.) directly, or building a StyleGAN2 generator/from a checkpoint/config that serializes an activation string other than 'fused_lrelu' or None.
Common situations: Porting a StyleGAN2 implementation that used a different activation name, editing the face-enhancement pipeline (experiments_face.py / pfn arch) to try a new activation, or deserializing a model config written for another repo where the same class accepts 'fused_lrelu' spelled differently.
Related errors
- Wrong sample mode {self.sample_mode}, supported ones are ['u
- Wrong activation value in EqualLinear: {activation}Supported
- Max depth of recursive function `tie_encoder_to_decoder` rea
- invalid distribution {distribution}
- network_name={network_name}
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/30e12c1c1426691f.
Report an issue: GitHub.