{"record":{"id":"43bf617873af0752","repo":"lllyasviel/Fooocus","slug":"activation-layer-s-is-not-found","errorCode":null,"errorMessage":"activation layer [{:s}] is not found","messagePattern":"activation layer \\[(.+?)\\] is not found","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"ldm_patched/pfn/architecture/block.py","lineNumber":32,"sourceCode":"\n####################\n# Basic blocks\n####################\n\n\ndef act(act_type: str, inplace=True, neg_slope=0.2, n_prelu=1):\n    # helper selecting activation\n    # neg_slope: for leakyrelu and init of prelu\n    # n_prelu: for p_relu num_parameters\n    act_type = act_type.lower()\n    if act_type == \"relu\":\n        layer = nn.ReLU(inplace)\n    elif act_type == \"leakyrelu\":\n        layer = nn.LeakyReLU(neg_slope, inplace)\n    elif act_type == \"prelu\":\n        layer = nn.PReLU(num_parameters=n_prelu, init=neg_slope)\n    else:\n        raise NotImplementedError(\n            \"activation layer [{:s}] is not found\".format(act_type)\n        )\n    return layer\n\n\ndef norm(norm_type: str, nc: int):\n    # helper selecting normalization layer\n    norm_type = norm_type.lower()\n    if norm_type == \"batch\":\n        layer = nn.BatchNorm2d(nc, affine=True)\n    elif norm_type == \"instance\":\n        layer = nn.InstanceNorm2d(nc, affine=False)\n    else:\n        raise NotImplementedError(\n            \"normalization layer [{:s}] is not found\".format(norm_type)\n        )\n    return layer\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/ldm_patched/pfn/architecture/block.py#L14-L50","documentation":"block.act() is the activation factory for the BasicSR-derived blocks (used by RRDB/SPSR/etc. conv blocks). After lowercasing, it knows exactly 'relu', 'leakyrelu' and 'prelu'; any other act_type raises NotImplementedError. Notably absent: 'gelu', 'silu'/'swish', 'elu' that other BasicSR forks support.","triggerScenarios":"Building a conv_block/RRDBNet with act_type='silu', 'gelu', 'elu', 'true' or any string not in the three supported names; the value comes from the model config dict (act key) of an upscaler definition.","commonSituations":"Porting a Real-ESRGAN config written for a newer BasicSR that supports more activations; hand-edited YAMLs; typos like 'LeakyRelu' are fine (lowercased) but 'lrelu' is NOT accepted - the full name 'leakyrelu' is required.","solutions":["Use one of: 'relu', 'leakyrelu', 'prelu' (note: 'lrelu' shorthand is not accepted)","If the source config used another activation, map it to the closest supported one (silu->leakyrelu) or extend act() with the missing branch","Validate the act string in your config loader before constructing the network"],"exampleFix":"# before\nconv = B.conv_block(64, 64, act_type='lrelu')  # -> NotImplementedError\n\n# after\nconv = B.conv_block(64, 64, act_type='leakyrelu')","handlingStrategy":"validation","validationCode":"SUPPORTED_ACTS = {'relu', 'leakyrelu', 'prelu'}\n\nact_type = cfg.get('act', 'leakyrelu').lower()\nif act_type == 'lrelu':  # common shorthand\n    act_type = 'leakyrelu'\nassert act_type in SUPPORTED_ACTS, f'activation must be one of {SUPPORTED_ACTS}, got {act_type!r}'","typeGuard":"def is_supported_act(act_type: str) -> bool:\n    return isinstance(act_type, str) and act_type.lower() in ('relu', 'leakyrelu', 'prelu')","tryCatchPattern":null,"preventionTips":["Use the exact names 'relu'/'leakyrelu'/'prelu' ('lrelu' shorthand is rejected)","Map or reject silu/gelu in your config loader before building conv blocks"],"tags":["super-resolution","activation","block","config","notimplementederror"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}