{"record":{"id":"09fc26a1387555a0","repo":"opendatalab/MinerU","slug":"unsupported-activation-name","errorCode":null,"errorMessage":"Unsupported activation: {name}","messagePattern":"Unsupported activation: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/model/utils/pytorchocr/modeling/backbones/rec_lcnetv4.py","lineNumber":76,"sourceCode":"            [[3, 512, 768, (2, 1), False], [3, 768, 768, 1, True], [3, 768, 768, 1, False]],\n        ],\n    },\n}\n\n\ndef _build_activation(name):\n    \"\"\"按 PP-OCRv6 配置创建无参数激活层，便于和 safetensors 权重命名保持解耦。\"\"\"\n    if name is None:\n        return nn.Identity()\n    if name == \"relu\":\n        return nn.ReLU()\n    if name == \"gelu\":\n        return nn.GELU()\n    if name in {\"silu\", \"swish\"}:\n        return nn.SiLU()\n    if name == \"hardsigmoid\":\n        return nn.Hardsigmoid()\n    raise ValueError(f\"Unsupported activation: {name}\")\n\n\ndef _to_stride(stride):\n    \"\"\"把 Paddle/Transformers 配置里的 stride 统一成 PyTorch 可接受的格式。\"\"\"\n    if isinstance(stride, list):\n        return tuple(stride)\n    return stride\n\n\nclass PPLCNetV4ConvLayer(nn.Module):\n    \"\"\"PP-LCNetV4 的 Conv-BN-Act 基础层，属性名对齐 HF 权重。\"\"\"\n\n    def __init__(\n        self,\n        in_channels,\n        out_channels,\n        kernel_size,\n        stride=1,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/utils/pytorchocr/modeling/backbones/rec_lcnetv4.py#L58-L94","documentation":"Raised by _build_activation in the PP-LCNetV4 recognition backbone when a block config names an activation that the factory cannot map. Supported names are relu, gelu, silu/swish, hardsigmoid (plus None -> Identity). It exists so HF/Paddle config strings map cleanly onto parameterless torch nn layers.","triggerScenarios":"Instantiating PPLCNetV4 backbone with a hand-modified NET_CONFIG (or passing config dicts) that use strings like 'hard_swish', 'relu6', 'sigmoid', or 'GELU' (case-sensitive).","commonSituations":"Porting LCNet configs from PaddleOCR/HF where 'hard_swish' is standard; editing the v4 block tables to experiment; case mismatches.","solutions":["Use only the supported activation names: relu, gelu, silu (or swish), hardsigmoid, or None.","If you need hard_swish, map it explicitly: hard_swish == hardsigmoid-family activation — extend _build_activation with nn.Hardswish if you control the fork.","Restore the shipped NET_CONFIG_REC/NET_CONFIG_DET tables if they were edited."],"exampleFix":"# before (fork edit)\nif name == \"hard_swish\": ...\n# config uses \"hard_swish\" -> raises\n\n# after\n_build_activation accepts \"hard_swish\":\n    if name in {\"hardsigmoid\", \"hard_sigmoid\"}:\n        return nn.Hardsigmoid()\n    if name == \"hard_swish\":\n        return nn.Hardswish()","handlingStrategy":"validation","validationCode":"SUPPORTED_ACT = {None, \"relu\", \"gelu\", \"silu\", \"swish\", \"hardsigmoid\"}\nassert act_name in SUPPORTED_ACT, f\"unsupported activation: {act_name!r}\"","typeGuard":"def is_supported_activation(name) -> bool:\n    return name in {None, \"relu\", \"gelu\", \"silu\", \"swish\", \"hardsigmoid\"}","tryCatchPattern":null,"preventionTips":["Do not edit shipped NET_CONFIG tables without checking the activation factory","Map Paddle names (hard_swish etc.) explicitly when porting configs"],"tags":["ocr","backbone","lcnet","activation","config","valueerror"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}