chenxie95 / deeplearning_course_sjtu

13 stars 2 forks source link

Sound_event_detection的baseline Crnn的init keyword报错 #5

Open Shentl opened 2 years ago

Shentl commented 2 years ago

Sound_event_detection中跑baseline时,run.py line 111 为 model = getattr(models, config['model']["type"])( inputdim=trainloader.dataset.datadim, outputdim=len(label_to_idx), **config['model']['args']) (baseline.yaml 中 model:type: Crnn) 其中models.Crnn () 用法应该是 def init(self, num_freq: Any, class_num: Any) -> None

会报错 init() got an unexpected keyword argument 'inputdim'

wsntxxn commented 2 years ago

已修改,将 inputdim 改成 num_freq,outputdim 改成 classes_num 即可

Shentl commented 2 years ago

改完后, model = model.to(DEVICE) 时出现 'Crnn' object has no attribute '_modules'

wsntxxn commented 2 years ago

https://discuss.pytorch.org/t/network-object-has-no-attribute-modules/45123

BravoFr0st commented 2 years ago

改完后, model = model.to(DEVICE) 时出现 'Crnn' object has no attribute '_modules'

https://discuss.pytorch.org/t/network-object-has-no-attribute-modules/45123

需要修改哪个文件中的哪一部分呢🤔

wsntxxn commented 2 years ago

继承了 nn.Module 的类初始化的时候要 super().init(),否则没有注册 modules

BravoFr0st commented 2 years ago

是需要先实现Crnn结构之后再跑是吧

wsntxxn commented 2 years ago

是的