{"record":{"id":"15f4a9eac869e461","repo":"lllyasviel/Fooocus","slug":"wrong-activation-value-in-equallinear-activation-15f4a9","errorCode":null,"errorMessage":"Wrong activation value in EqualLinear: {activation}Supported ones are: ['fused_lrelu', None].","messagePattern":"Wrong activation value in EqualLinear: (.+?)Supported ones are: \\['fused_lrelu', None\\]\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ldm_patched/pfn/architecture/face/stylegan2_bilinear_arch.py","lineNumber":52,"sourceCode":"            Supported: 'fused_lrelu', None. Default: None.\n    \"\"\"\n\n    def __init__(\n        self,\n        in_channels,\n        out_channels,\n        bias=True,\n        bias_init_val=0,\n        lr_mul=1,\n        activation=None,\n    ):\n        super(EqualLinear, self).__init__()\n        self.in_channels = in_channels\n        self.out_channels = out_channels\n        self.lr_mul = lr_mul\n        self.activation = activation\n        if self.activation not in [\"fused_lrelu\", None]:\n            raise ValueError(\n                f\"Wrong activation value in EqualLinear: {activation}\"\n                \"Supported ones are: ['fused_lrelu', None].\"\n            )\n        self.scale = (1 / math.sqrt(in_channels)) * lr_mul\n\n        self.weight = nn.Parameter(torch.randn(out_channels, in_channels).div_(lr_mul))\n        if bias:\n            self.bias = nn.Parameter(torch.zeros(out_channels).fill_(bias_init_val))\n        else:\n            self.register_parameter(\"bias\", None)\n\n    def forward(self, x):\n        if self.bias is None:\n            bias = None\n        else:\n            bias = self.bias * self.lr_mul\n        if self.activation == \"fused_lrelu\":\n            out = F.linear(x, self.weight * self.scale)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/ldm_patched/pfn/architecture/face/stylegan2_bilinear_arch.py#L34-L70","documentation":"Identical guard to the one in stylegan2_arch.py, but in the bilinear-backbone variant ldm_patched/pfn/architecture/face/stylegan2_bilinear_arch.py. This EqualLinear only supports activation=None or 'fused_lrelu' because the bilinear variant replaces fused up/down sampling and thus has no other fused activation paths. Any other activation string raises ValueError at construction.","triggerScenarios":"Building the bilinear StyleGAN2 face model with EqualLinear(..., activation=<anything except 'fused_lrelu' or None>), typically when copying layer code from the non-bilinear file that was modified to use another activation.","commonSituations":"Diverging the two stylegan2_arch / stylegan2_bilinear_arch copies and applying an activation change to only one; loading a face-model config tuned against a different implementation.","solutions":["Pass activation=None or 'fused_lrelu'.","If you patched stylegan2_arch.py to support a new activation, apply the matching patch to stylegan2_bilinear_arch.py (and vice versa) so the two vendored copies stay consistent.","Apply custom activations outside EqualLinear in the caller's forward()."],"exampleFix":"// before\nEqualLinear(num_style_feat, in_channels, activation='relu')\n// after\nEqualLinear(num_style_feat, in_channels, activation=None)","handlingStrategy":"validation","validationCode":"valid = {None, 'fused_lrelu'}\nassert activation in valid, f'activation must be one of {valid}, got {activation!r}'","typeGuard":"def is_equal_linear_activation(v) -> bool:\n    return v is None or (isinstance(v, str) and v == 'fused_lrelu')","tryCatchPattern":null,"preventionTips":["Treat stylegan2_arch.py and stylegan2_bilinear_arch.py as a pair: any change to accepted values must go into both.","Diff the two vendored files before modifying either."],"tags":["pytorch","stylegan","face-restoration","constructor-validation","code-duplication"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}