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_custom
RuntimeError: Given groups=1, weight of size [32, 17, 1], expected input[16, 1, 128] to have 17 channels, but got 1 channels instead
The in_channel argument is simply due to the following thread
opened 03:50PM - 04 Apr 23 UTC
This 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?
hey @StableDiffuser317 Iโ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