{"record":{"id":"9ef2be3fca423be7","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"the-inverted-residual-setting-should-not-be-empty-9ef2be","errorCode":null,"errorMessage":"The inverted_residual_setting should not be empty.","messagePattern":"The inverted_residual_setting should not be empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pytorch_segmentation/deeplab_v3/src/mobilenet_backbone.py","lineNumber":159,"sourceCode":"    def forward(self, x: Tensor) -> Tensor:\n        result = self.block(x)\n        if self.use_res_connect:\n            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,","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_segmentation/deeplab_v3/src/mobilenet_backbone.py#L141-L177","documentation":"MobileNetV3's __init__ requires a non-empty inverted_residual_setting list describing the block stack. An empty (falsy) value would produce a model with no feature blocks, so it raises ValueError immediately rather than building a broken network.","triggerScenarios":"Calling MobileNetV3(inverted_residual_setting=[]) or omitting/None-ing the setting without passing a preset name, e.g. building the model with an empty custom config.","commonSituations":"Constructing the model programmatically with a config list that ended up empty (filtered out all blocks); forgetting to import/use the provided mobilev3_large_150/mobilev3_small_100 settings builders.","solutions":["Pass a real config list, e.g. use the provided mobilev3_large_150(num_classes=...) or mobilev3_small_100(...) factory functions.","Populate inverted_residual_setting with valid InvertedResidualConfig entries.","Check upstream code that builds the settings list for filtering bugs that empty it."],"exampleFix":"// before\nmodel = MobileNetV3(inverted_residual_setting=[], num_classes=20)\n// after\nfrom src.mobilenet_backbone import mobilev3_large_150\nmodel = mobilev3_large_150(num_classes=20)","handlingStrategy":"validation","validationCode":"assert inverted_residual_setting, \"inverted_residual_setting must be non-empty\"","typeGuard":"def is_nonempty_config_list(settings) -> bool:\n    return bool(settings)","tryCatchPattern":"try:\n    model = MobileNetV3(inverted_residual_setting=settings, num_classes=n)\nexcept ValueError as e:\n    logging.error(f\"{e}; len(settings)={len(settings) if settings else 0}\"); raise","preventionTips":["Use mobilev3_large_150/mobilev3_small_100 factories instead of manual lists","Check filtering code that could empty the settings list","Unit-test model construction after any config-generation change"],"tags":["value-error","mobilenet","empty-config","configuration"],"backgroundTag":"empty-block-configuration","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}