{"record":{"id":"df740a1b7562c0c8","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"the-inverted-residual-setting-should-be-list-inver-df740a","errorCode":null,"errorMessage":"The inverted_residual_setting should be List[InvertedResidualConfig]","messagePattern":"The inverted_residual_setting should be List\\[InvertedResidualConfig\\]","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pytorch_segmentation/deeplab_v3/src/mobilenet_backbone.py","lineNumber":162,"sourceCode":"            result += x\n\n        return result\n\n\nclass MobileNetV3(nn.Module):\n    def __init__(self,\n                 inverted_residual_setting: List[InvertedResidualConfig],\n                 last_channel: int,\n                 num_classes: int = 1000,\n                 block: Optional[Callable[..., nn.Module]] = None,\n                 norm_layer: Optional[Callable[..., nn.Module]] = None):\n        super(MobileNetV3, self).__init__()\n\n        if not inverted_residual_setting:\n            raise ValueError(\"The inverted_residual_setting should not be empty.\")\n        elif not (isinstance(inverted_residual_setting, List) and\n                  all([isinstance(s, InvertedResidualConfig) for s in inverted_residual_setting])):\n            raise TypeError(\"The inverted_residual_setting should be List[InvertedResidualConfig]\")\n\n        if block is None:\n            block = InvertedResidual\n\n        if norm_layer is None:\n            norm_layer = partial(nn.BatchNorm2d, eps=0.001, momentum=0.01)\n\n        layers: List[nn.Module] = []\n\n        # building first layer\n        firstconv_output_c = inverted_residual_setting[0].input_c\n        layers.append(ConvBNActivation(3,\n                                       firstconv_output_c,\n                                       kernel_size=3,\n                                       stride=2,\n                                       norm_layer=norm_layer,\n                                       activation_layer=nn.Hardswish))\n        # building inverted residual blocks","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_segmentation/deeplab_v3/src/mobilenet_backbone.py#L144-L180","documentation":"Besides being non-empty, inverted_residual_setting must be a List whose every element is an InvertedResidualConfig. Otherwise the model cannot safely read each block's fields, so __init__ raises TypeError naming the expected type.","triggerScenarios":"Passing inverted_residual_setting as a tuple, dict, or a list of plain dicts/dataclass-like objects that are not InvertedResidualConfig instances.","commonSituations":"Building block configs as raw dicts instead of InvertedResidualConfig; mixing configs copied from torchvision's MobileNetV3 (different dataclass) with this repo's implementation; JSON-loaded configs.","solutions":["Convert each entry to InvertedResidualConfig with the right field order/values.","Use the repo's factory functions (mobilev3_large_150 / mobilev3_small_100) instead of hand-built lists.","If you have dicts, map them: [InvertedResidualConfig(**d) for d in settings] after verifying fields."],"exampleFix":"// before\nsettings = [{\"input_c\": 16, \"kernel\": 3, \"expanded_c\": 64, ...}]\nmodel = MobileNetV3(inverted_residual_setting=settings)\n// after\nsettings = [InvertedResidualConfig(16, 3, 16, 16, False, \"RE\", 1, 1, 1)]\nmodel = MobileNetV3(inverted_residual_setting=settings)","handlingStrategy":"type-guard","validationCode":"from src.mobilenet_backbone import InvertedResidualConfig\nassert isinstance(settings, list) and all(isinstance(s, InvertedResidualConfig) for s in settings)","typeGuard":"from src.mobilenet_backbone import InvertedResidualConfig\ndef is_valid_settings(settings) -> bool:\n    return isinstance(settings, list) and all(isinstance(s, InvertedResidualConfig) for s in settings)","tryCatchPattern":"try:\n    model = MobileNetV3(inverted_residual_setting=settings, num_classes=n)\nexcept TypeError as e:\n    logging.error(f\"{e}; types={[type(s).__name__ for s in settings]}\"); raise","preventionTips":["Convert dict configs with InvertedResidualConfig(**d)","Do not mix torchvision MobileNetV3 configs with this repo's class","Prefer the repo's preset builder functions"],"tags":["type-error","mobilenet","configuration","type-check"],"backgroundTag":"invalid-block-config-type","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}