Unet1dmodel fails
Specifying the architecture of a Unet1dmodel leads to weird behaviour.CODE :default_model = UNet1DModel(in_channels = 17, out_channels=1,sample_size = 256)custom_model = UNet1DModel(in_channels = 17, out_channels=1,sample_size = 256,down_block_types =(“DownBlock1D”, “DownBlock1D”, “DownBlock1D”,“DownBlock1D”,“DownBlock1D”),up_block_types = (“UpBlock1D”, “UpBlock1D”,“UpBlock1D”,“UpBlock1D”, “UpBlock1D”),block_out_channels = (32, 32, 32, 32, 32))x = torch.randn((16,1,256))timesteps = torch.randint(0,10,(16,))y_default = default_model(x,timesteps)y_custom = custom_model(x,timesteps)ERROR :Regarding y_customRuntimeError: Given groups=1, weight of size [32, 17, 1], expected input[16, 1, 128] to have 17 channels, but got 1 channels insteadThe in_channel argument is simply due to the following threadgithub.com/huggingface/diffusersCannot get simple UNet1D to runopened03:50PM - 04 Apr 23 UTCturianThis is using the latest huggingface diffusers:

```
from diffusers.models.un…et_1d import UNet1DModel
import torch

net = UNet1DModel().cuda()
input_data = torch.rand(1, 2, 16000).cuda()
net(input_data, 1)
```

gives the following:

```
╭─────────────────────────────── Traceback (most recent call last) ───────────────────────────────╮
│ <ipython-input-4-fe6e05ad0774>:1 in <module>                                                    │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py:1194 in _call_impl       │
│                                                                                                 │
│   1191 │   │   # this function, and just call forward.                                          │
│   1192 │   │   if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks o │
│   1193 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                  │
│ ❱ 1194 │   │   │   return forward_call(*input, **kwargs)                                        │
│   1195 │   │   # Do not call functions when jit is used                                         │
│   1196 │   │   full_backward_hooks, non_full_backward_hooks = [], []                            │
│   1197 │   │   if self._backward_hooks or _global_backward_hooks:                               │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/diffusers/models/unet_1d.py:226 in forward          │
│                                                                                                 │
│   223 │   │   # 2. down                                                                         │
│   224 │   │   down_block_res_samples = ()                                                       │
│   225 │   │   for downsample_block in self.down_blocks:                                         │
│ ❱ 226 │   │   │   sample, res_samples = downsample_block(hidden_states=sample, temb=timestep_e  │
│   227 │   │   │   down_block_res_samples += res_samples                                         │
│   228 │   │                                                                                     │
│   229 │   │   # 3. mid                                                                          │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py:1194 in _call_impl       │
│                                                                                                 │
│   1191 │   │   # this function, and just call forward.                                          │
│   1192 │   │   if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks o │
│   1193 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                  │
│ ❱ 1194 │   │   │   return forward_call(*input, **kwargs)                                        │
│   1195 │   │   # Do not call functions when jit is used                                         │
│   1196 │   │   full_backward_hooks, non_full_backward_hooks = [], []                            │
│   1197 │   │   if self._backward_hooks or _global_backward_hooks:                               │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/diffusers/models/unet_1d_blocks.py:524 in forward   │
│                                                                                                 │
│   521 │   def forward(self, hidden_states, temb=None):                                          │
│   522 │   │   hidden_states = torch.cat([hidden_states, temb], dim=1)                           │
│   523 │   │   for resnet in self.resnets:                                                       │
│ ❱ 524 │   │   │   hidden_states = resnet(hidden_states)                                         │
│   525 │   │                                                                                     │
│   526 │   │   return hidden_states, (hidden_states,)                                            │
│   527                                                                                           │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py:1194 in _call_impl       │
│                                                                                                 │
│   1191 │   │   # this function, and just call forward.                                          │
│   1192 │   │   if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks o │
│   1193 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                  │
│ ❱ 1194 │   │   │   return forward_call(*input, **kwargs)                                        │
│   1195 │   │   # Do not call functions when jit is used                                         │
│   1196 │   │   full_backward_hooks, non_full_backward_hooks = [], []                            │
│   1197 │   │   if self._backward_hooks or _global_backward_hooks:                               │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/diffusers/models/unet_1d_blocks.py:400 in forward   │
│                                                                                                 │
│   397 │   │   │   self.gelu_2 = nn.GELU()                                                       │
│   398 │                                                                                         │
│   399 │   def forward(self, hidden_states):                                                     │
│ ❱ 400 │   │   residual = self.conv_skip(hidden_states) if self.has_conv_skip else hidden_state  │
│   401 │   │                                                                                     │
│   402 │   │   hidden_states = self.conv_1(hidden_states)                                        │
│   403 │   │   hidden_states = self.group_norm_1(hidden_states)                                  │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py:1194 in _call_impl       │
│                                                                                                 │
│   1191 │   │   # this function, and just call forward.                                          │
│   1192 │   │   if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks o │
│   1193 │   │   │   │   or _global_forward_hooks or _global_forward_pre_hooks):                  │
│ ❱ 1194 │   │   │   return forward_call(*input, **kwargs)                                        │
│   1195 │   │   # Do not call functions when jit is used                                         │
│   1196 │   │   full_backward_hooks, non_full_backward_hooks = [], []                            │
│   1197 │   │   if self._backward_hooks or _global_backward_hooks:                               │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/conv.py:313 in forward             │
│                                                                                                 │
│    310 │   │   │   │   │   │   self.padding, self.dilation, self.groups)                        │
│    311 │                                                                                        │
│    312 │   def forward(self, input: Tensor) -> Tensor:                                          │
│ ❱  313 │   │   return self._conv_forward(input, self.weight, self.bias)                         │
│    314                                                                                          │
│    315                                                                                          │
│    316 class Conv2d(_ConvNd):                                                                   │
│                                                                                                 │
│ /opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/conv.py:309 in _conv_forward       │
│                                                                                                 │
│    306 │   │   │   return F.conv1d(F.pad(input, self._reversed_padding_repeated_twice, mode=sel │
│    307 │   │   │   │   │   │   │   weight, bias, self.stride,                                   │
│    308 │   │   │   │   │   │   │   _single(0), self.dilation, self.groups)                      │
│ ❱  309 │   │   return F.conv1d(input, weight, bias, self.stride,                                │
│    310 │   │   │   │   │   │   self.padding, self.dilation, self.groups)                        │
│    311 │                                                                                        │
│    312 │   def forward(self, input: Tensor) -> Tensor:                                          │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Given groups=1, weight of size [32, 2, 1], expected input[1, 18, 16000] to have 2
channels, but got 18 channels instead
```

Why? Shouldn't the default parameters work out of the box?
2023-04-14T01:13:26Z
hey@StableDiffuser317I’m not sure how much time we have to prioritize debugging the 1 dimensional unet beyond the default configuration but please feel free to do some digging and open a PR updating the misconfiguration