# Model input shape doesnt match

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-input-shape-doesnt-match%2F150085%3E%5C
**Category:** Beginners\
**Created:** [April 12, 2025, 10:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-input-shape-doesnt-match%2F150085 "2025-04-12T10:22:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LukasUni](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@LukasUni](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FLukasUni)%5C
**Post date:** [April 12, 2025, 10:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-input-shape-doesnt-match%2F150085%2F1 "2025-04-12T10:22:19Z")

</div>

Hello,

with the following Code

```auto
from diffusers import UNet1DModel
import torch
import torch.nn as nn
class ClassConditionedUned(nn.Module):
    def __init__ (self, num_ela=8, class_emb_size=4):
        super(). __init__ ()
        self.class_emb = nn.Sequential(
            nn.Linear(num_ela, 32),
            nn.ReLU(),
            nn.Linear(32, class_emb_size)
        )
        self.model = UNet1DModel(
            sample_size=512,
            in_channels=1+class_emb_size,
            out_channels=1,
            layers_per_block=1,  
            block_out_channels = (32, 32, 64),   
            down_block_types = ("DownBlock1DNoSkip", "DownBlock1D", "AttnDownBlock1D"),
            up_block_types = ("AttnUpBlock1D", "UpBlock1D", "UpBlock1DNoSkip"),   
        )
        
    def forward(self, x, t, ela_vec):
        bs, ch, h = x.shape
        class_cond = self.class_emb(ela_vec) # Map to embedding dimension
        class_cond = class_cond.view(bs, -1, 1).expand(-1, -1, h)
        net_input = torch.cat((x, class_cond), 1)
        print(net_input.shape)
        return self.model(net_input, t).sample

model = ClassConditionedUned()
x = torch.randn(1, 1, 512)
t = torch.randint(0, 1000, (1,))
ela_vec = torch.rand(1, 8) # normalisierte ELA-Vektoren

with torch.no_grad():
    out = model(x, t, ela_vec)

```

i get this error:  
out = model(x, t, ela\_vec)  
^^^^^^^^^^^^^^^^^^^^  
RuntimeError: Given groups=1, weight of size [32, 5, 1], expected input[1, 21, 512] to have 5 channels, but got 21 channels instead

What am i doing wrong?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![LukasUni](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@LukasUni](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FLukasUni)%5C
**Post date:** [April 12, 2025, 11:04am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-input-shape-doesnt-match%2F150085%2F2 "2025-04-12T11:04:39Z")

</div>

this solvers my issue: [https://github.com/huggingface/diffusers/issues/2967#issuecomment-1500800012](https://github.com/huggingface/diffusers/issues/2967#issuecomment-1500800012)  
i had to add 16 to the input channels

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [April 12, 2025, 11:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-input-shape-doesnt-match%2F150085%2F3 "2025-04-12T23:05:32Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
