{"record":{"id":"a22f47aee51040b5","repo":"huggingface/pytorch-image-models","slug":"features-only-not-implemented-for-convmixer-models","errorCode":null,"errorMessage":"features_only not implemented for ConvMixer models.","messagePattern":"features_only not implemented for ConvMixer models\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"timm/models/convmixer.py","lineNumber":114,"sourceCode":"            x = checkpoint_seq(self.blocks, x)\n        else:\n            x = self.blocks(x)\n        return x\n\n    def forward_head(self, x, pre_logits: bool = False):\n        x = self.pooling(x)\n        x = self.head_drop(x)\n        return x if pre_logits else self.head(x)\n\n    def forward(self, x):\n        x = self.forward_features(x)\n        x = self.forward_head(x)\n        return x\n\n\ndef _create_convmixer(variant, pretrained=False, **kwargs):\n    if kwargs.get('features_only', None):\n        raise RuntimeError('features_only not implemented for ConvMixer models.')\n\n    return build_model_with_cfg(ConvMixer, variant, pretrained, **kwargs)\n\n\ndef _cfg(url='', **kwargs):\n    return {\n        'url': url,\n        'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': None,\n        'crop_pct': .96, 'interpolation': 'bicubic',\n        'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'classifier': 'head',\n        'first_conv': 'stem.0', 'license': 'mit',\n        **kwargs\n    }\n\n\ndefault_cfgs = generate_default_cfgs({\n    'convmixer_1536_20.in1k': _cfg(hf_hub_id='timm/'),\n    'convmixer_768_32.in1k': _cfg(hf_hub_id='timm/'),","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/models/convmixer.py#L96-L132","documentation":"ConvMixer factory functions reject features_only=True. ConvMixer is a stack of identical conv+patch-embed blocks without hierarchical stages, so it does not register the feature_locations needed by timm's feature extraction wrapper; _create_convmixer raises immediately.","triggerScenarios":"Calling timm.create_model('convmixer_1024_20_ks9_p14', features_only=True) (or the 1536/768 variants) with features_only truthy.","commonSituations":"Reuse of detection/segmentation scaffold code that unconditionally sets features_only=True; assuming feature-extraction support is uniform across timm models.","solutions":["Drop features_only and use forward_intermediates to obtain intermediate ConvMixer block outputs","If true multi-scale maps are needed, choose a hierarchical backbone (e.g. ResNet, ConvNeXt, EfficientNet)","Register a custom feature_cfgs via timm's build_model_with_cfg escape hatch only if you fully control the wrapper"],"exampleFix":"# before\nmodel = timm.create_model('convmixer_1536_20', features_only=True)\n# after\nmodel = timm.create_model('convmixer_1536_20')\nfeats = model.forward_intermediates(x, indices=[5, 10, 15, 19])","handlingStrategy":"validation","validationCode":"import timm\nm = timm.create_model('convmixer_1024_20_ks9_p14')\nassert not hasattr(m, 'feature_info'), 'no feature_info; do not pass features_only'\nmodel = timm.create_model('convmixer_1024_20_ks9_p14')","typeGuard":"def supports_features_only(name: str) -> bool:\n    import timm\n    m = timm.create_model(name)\n    ok = hasattr(m, 'feature_info')\n    del m\n    return ok","tryCatchPattern":"try:\n    model = timm.create_model(variant, features_only=True)\nexcept RuntimeError:\n    model = timm.create_model(variant)","preventionTips":["Validate features_only support before construction","Use forward_intermediates for uniform feature APIs","Keep a backbone allowlist for detection/segmentation training"],"tags":["timm","convmixer","features-only","unsupported-operation"],"backgroundTag":"unsupported-features-only-request","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}