{"record":{"id":"aa2ef37f67ccc063","repo":"huggingface/pytorch-image-models","slug":"the-output-channel-self-output-size-is-different","errorCode":null,"errorMessage":"The output channel {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":114,"sourceCode":"                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\n    def forward(self, x):\n        B, H, W, C = x.shape\n\n        if self.with_vertical:","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/models/sequencer.py#L96-L132","documentation":"For union='add', the two RNN branches are summed, so output_size must equal input_size. A mismatch means the residual/add path would change channel count and construction aborts.","triggerScenarios":"SequencerBlock(union='add') with output_size != input_size, e.g. trying to change widths mid-stage while reusing an 'add' block config.","commonSituations":"Scaling sequencer widths per stage but copying a block template that uses union='add'.","solutions":["Set output_size = input_size for 'add' blocks","Or use union='cat' with output_size = input_size // 2 when you need a width change"],"exampleFix":"# before\nSequencerBlock(dim, dim * 2, union='add')\n# after\nSequencerBlock(dim, dim, union='add')","handlingStrategy":"validation","validationCode":"if union == 'add':\n    assert output_size == input_size, 'add requires output_size == input_size'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use equal in/out dims for residual-style blocks","Unit-test custom configs construct successfully"],"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"}