opendatalab/MinerU · error · ValueError
Unsupported activation: {name}
Error message
Unsupported activation: {name} What it means
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.
Source
Thrown at mineru/model/utils/pytorchocr/modeling/backbones/rec_lcnetv4.py:76
[[3, 512, 768, (2, 1), False], [3, 768, 768, 1, True], [3, 768, 768, 1, False]],
],
},
}
def _build_activation(name):
"""按 PP-OCRv6 配置创建无参数激活层,便于和 safetensors 权重命名保持解耦。"""
if name is None:
return nn.Identity()
if name == "relu":
return nn.ReLU()
if name == "gelu":
return nn.GELU()
if name in {"silu", "swish"}:
return nn.SiLU()
if name == "hardsigmoid":
return nn.Hardsigmoid()
raise ValueError(f"Unsupported activation: {name}")
def _to_stride(stride):
"""把 Paddle/Transformers 配置里的 stride 统一成 PyTorch 可接受的格式。"""
if isinstance(stride, list):
return tuple(stride)
return stride
class PPLCNetV4ConvLayer(nn.Module):
"""PP-LCNetV4 的 Conv-BN-Act 基础层,属性名对齐 HF 权重。"""
def __init__(
self,
in_channels,
out_channels,
kernel_size,
stride=1,View on GitHub (pinned to 4fe4bde114)
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.
Example fix
# before (fork edit)
if name == "hard_swish": ...
# config uses "hard_swish" -> raises
# after
_build_activation accepts "hard_swish":
if name in {"hardsigmoid", "hard_sigmoid"}:
return nn.Hardsigmoid()
if name == "hard_swish":
return nn.Hardswish() Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_ACT = {None, "relu", "gelu", "silu", "swish", "hardsigmoid"}
assert act_name in SUPPORTED_ACT, f"unsupported activation: {act_name!r}" Type guard
def is_supported_activation(name) -> bool:
return name in {None, "relu", "gelu", "silu", "swish", "hardsigmoid"} Prevention
- Do not edit shipped NET_CONFIG tables without checking the activation factory
- Map Paddle names (hard_swish etc.) explicitly when porting configs
When it happens
Trigger: 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).
Common situations: Porting LCNet configs from PaddleOCR/HF where 'hard_swish' is standard; editing the v4 block tables to experiment; case mismatches.
Related errors
- PPLCNetV4 {mode} model_size must be one of {list(config_dict
- PPLCNetV4 only supports 3 input channels, got {in_channels}.
- mode[{model_name}_model] is not implemented!
- mode[{model_name}_model] is not implemented!
- The mixer must be one of [Global, Local, Conv]
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/09fc26a1387555a0.
Report an issue: GitHub.