{"record":{"id":"46e1fd50be1fc589","repo":"huggingface/pytorch-image-models","slug":"the-output-channel-2-self-output-size-is-diffe","errorCode":null,"errorMessage":"The output channel {2 * self.output_size} is different from the input channel {input_size}.","messagePattern":"The output channel (.+?) is different from the input channel (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/models/sequencer.py","lineNumber":110,"sourceCode":"\n        self.fc = None\n        if with_fc:\n            if union == \"cat\":\n                self.fc = nn.Linear(2 * self.output_size, input_size, **dd)\n            elif union == \"add\":\n                self.fc = nn.Linear(self.output_size, input_size, **dd)\n            elif union == \"vertical\":\n                self.fc = nn.Linear(self.output_size, input_size, **dd)\n                self.with_horizontal = False\n            elif union == \"horizontal\":\n                self.fc = nn.Linear(self.output_size, input_size, **dd)\n                self.with_vertical = False\n            else:\n                raise ValueError(\"Unrecognized union: \" + union)\n        elif union == \"cat\":\n            pass\n            if 2 * self.output_size != input_size:\n                raise ValueError(f\"The output channel {2 * self.output_size} is different from the input channel {input_size}.\")\n        elif union == \"add\":\n            pass\n            if self.output_size != input_size:\n                raise ValueError(f\"The output channel {self.output_size} is different from the input channel {input_size}.\")\n        elif union == \"vertical\":\n            if self.output_size != input_size:\n                raise ValueError(f\"The output channel {self.output_size} is different from the input channel {input_size}.\")\n            self.with_horizontal = False\n        elif union == \"horizontal\":\n            if self.output_size != input_size:\n                raise ValueError(f\"The output channel {self.output_size} is different from the input channel {input_size}.\")\n            self.with_vertical = False\n        else:\n            raise ValueError(\"Unrecognized union: \" + union)\n\n        self.rnn_v = RNNIdentity()\n        self.rnn_h = RNNIdentity()\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/models/sequencer.py#L92-L128","documentation":"For union='cat', the block concatenates vertical and horizontal RNN branch outputs, so the input channel dimension must equal exactly 2 * output_size. If input_size != 2*output_size the shapes cannot be concatenated consistently and init fails.","triggerScenarios":"Configuring a SequencerBlock(union='cat') where the preceding layer's dim (input_size) is not twice this block's output_size — e.g. hand-edited channel progression between stages.","commonSituations":"Customizing sequencer depths/dims without scaling paired stages so that channels double/halve correctly at cat junctions.","solutions":["Set output_size = input_size // 2 for the cat block","Or switch union to 'add'/'vertical'/'horizontal' where output_size must equal input_size","Revert to the pretrained variant's stock dims"],"exampleFix":"# before\nSequencerBlock(dim, dim // 4, union='cat')\n# after\nSequencerBlock(dim, dim // 2, union='cat')","handlingStrategy":"validation","validationCode":"if union == 'cat':\n    assert input_size == 2 * output_size, 'cat requires input_size == 2 * output_size'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep width transitions at stage boundaries, not inside cat blocks","Programmatically derive block dims from stage dims"],"tags":["timm","sequencer","shape-mismatch","config"],"backgroundTag":"channel-dimension-mismatch","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}