{"record":{"id":"30e12c1c1426691f","repo":"lllyasviel/Fooocus","slug":"wrong-activation-value-in-equallinear-activation","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_arch.py","lineNumber":168,"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":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/ldm_patched/pfn/architecture/face/stylegan2_arch.py#L150-L186","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nEqualLinear(512, 512, activation='lrelu')\n// after\nEqualLinear(512, 512, activation=None)  # then apply F.leaky_relu(out) yourself","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":["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."],"tags":["pytorch","stylegan","face-restoration","constructor-validation","model-config"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}