fschmid56 / EfficientAT

This repository aims at providing efficient CNNs for Audio Tagging. We provide AudioSet pre-trained models ready for downstream training and extraction of audio embeddings.
MIT License
229 stars 43 forks source link

Cannot load dymn20_as #23

Closed turian closed 10 months ago

turian commented 10 months ago
model = get_dymn(pretrained_name="dymn20_as")

gives

In [8]: get_dymn(pretrained_name="dymn20_as")
/opt/miniconda3/lib/python3.9/site-packages/torchvision/ops/misc.py:120: UserWarning: Don't use ConvNormActivation directly, please use Conv2dNormActivation and Conv3dNormActivation instead.
  warnings.warn(
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[8], line 1
----> 1 get_dymn(pretrained_name="dymn20_as")

File ~/dev/goodvibes/vocaltechnique/EfficientAT/models/dymn/model.py:321, in get_model(num_classes, pretrained_name, width_mult, strides, context_ratio, max_context_size, min_context_size, dyrelu_k, no_dyrelu, dyconv_k, no_dyconv, T_max, T0_slope, T1_slope, T_min, pretrain_final_temp, no_ca, use_dy_blocks)
    317     T_max = pretrain_final_temp
    319 temp_schedule = (T_max, T_min, T0_slope, T1_slope)
--> 321 m = dymn(num_classes=num_classes,
    322          pretrained_name=pretrained_name,
    323          block=block,
    324          width_mult=width_mult,
    325          strides=strides,
    326          context_ratio=context_ratio,
    327          max_context_size=max_context_size,
    328          min_context_size=min_context_size,
    329          dyrelu_k=dyrelu_k,
    330          dyconv_k=dyconv_k,
    331          no_dyrelu=no_dyrelu,
    332          no_dyconv=no_dyconv,
    333          no_ca=no_ca,
    334          temp_schedule=temp_schedule,
    335          use_dy_blocks=use_dy_blocks
    336          )
    337 print(m)
    338 return m

File ~/dev/goodvibes/vocaltechnique/EfficientAT/models/dymn/model.py:263, in dymn(pretrained_name, **kwargs)
    261 def dymn(pretrained_name: str = None, **kwargs: Any):
    262     inverted_residual_setting, last_channel = _dymn_conf(**kwargs)
--> 263     return _dymn(inverted_residual_setting, last_channel, pretrained_name, **kwargs)

File ~/dev/goodvibes/vocaltechnique/EfficientAT/models/dymn/model.py:257, in _dymn(inverted_residual_setting, last_channel, pretrained_name, **kwargs)
    255         model.load_state_dict(state_dict, strict=False)
    256     else:
--> 257         model.load_state_dict(state_dict)
    258 return model

File /opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py:2152, in Module.load_state_dict(self, state_dict, strict, assign)
   2147         error_msgs.insert(
   2148             0, 'Missing key(s) in state_dict: {}. '.format(
   2149                 ', '.join(f'"{k}"' for k in missing_keys)))
   2151 if len(error_msgs) > 0:
-> 2152     raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
   2153                        self.__class__.__name__, "\n\t".join(error_msgs)))
   2154 return _IncompatibleKeys(missing_keys, unexpected_keys)

RuntimeError: Error(s) in loading state_dict for DyMN:
    size mismatch for layers.0.depth_conv.weight: copying a param with shape torch.Size([1, 1, 4, 288]) from checkpoint, the shape in current model is torch.Size([1, 1, 4, 144]).
    size mismatch for layers.0.depth_conv.residuals.0.weight: copying a param with shape torch.Size([4, 64]) from checkpoint, the shape in current model is torch.Size([4, 32]).
    size mismatch for layers.0.depth_norm.weight: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.depth_norm.bias: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.depth_norm.running_mean: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.depth_norm.running_var: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.depth_act.coef_net.0.weight: copying a param with shape torch.Size([128, 64]) from checkpoint, the shape in current model is torch.Size([64, 32]).
    size mismatch for layers.0.depth_act.coef_net.0.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
    size mismatch for layers.0.proj_conv.weight: copying a param with shape torch.Size([1, 1, 4, 1024]) from checkpoint, the shape in current model is torch.Size([1, 1, 4, 256]).
    size mismatch for layers.0.proj_conv.residuals.0.weight: copying a param with shape torch.Size([4, 64]) from checkpoint, the shape in current model is torch.Size([4, 32]).
    size mismatch for layers.0.proj_norm.weight: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.proj_norm.bias: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.proj_norm.running_mean: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.proj_norm.running_var: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.context_gen.joint_conv.weight: copying a param with shape torch.Size([64, 32, 1, 1]) from checkpoint, the shape in current model is torch.Size([32, 16, 1, 1]).
    size mismatch for layers.0.context_gen.joint_norm.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
    size mismatch for layers.0.context_gen.joint_norm.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
    size mismatch for layers.0.context_gen.joint_norm.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
    size mismatch for layers.0.context_gen.joint_norm.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
    size mismatch for layers.0.context_gen.conv_f.weight: copying a param with shape torch.Size([32, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([16, 32, 1, 1]).
    size mismatch for layers.0.context_gen.conv_f.bias: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.0.context_gen.conv_t.weight: copying a param with shape torch.Size([32, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([16, 32, 1, 1]).
    size mismatch for layers.0.context_gen.conv_t.bias: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([16]).
    size mismatch for layers.1.exp_conv.weight: copying a param with shape torch.Size([1, 1, 4, 4096]) from checkpoint, the shape in current model is torch.Size([1, 1, 4, 1024]).
    size mismatch for layers.1.exp_conv.residuals.0.weight: copying a param with shape torch.Size([4, 64]) from checkpoint, the shape in current model is torch.Size([4, 32]).
    size mismatch for layers.1.exp_norm.weight: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
    size mismatch for layers.1.exp_norm.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
    size mismatch for layers.1.exp_norm.running_mean: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).

etc

turian commented 10 months ago

get_dymn(pretrained_name="dymn20_as", width_mult=2.0)

works