一.报错信息以及断点调试信息
1.报错信息
/data/cpf/Parrot_V3/vocoder/fregan/train.py:166: UserWarning: Using a target size (torch.Size([16, 80, 40])) that is different to the input size (torch.Size([16, 80, 32])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
loss_mel = F.l1_loss(y_mel, y_g_hat_mel) * 45
Traceback (most recent call last):
File "vocoder_train.py", line 77, in
train_fregan(0, args, h)
File "/data/cpf/Parrot_V3/vocoder/fregan/train.py", line 166, in train
loss_mel = F.l1_loss(y_mel, y_g_hat_mel) * 45
File "/home/llp/.conda/envs/pytorch/lib/python3.8/site-packages/torch/nn/functional.py", line 3080, in l1_loss
expanded_input, expanded_target = torch.broadcast_tensors(input, target)
File "/home/llp/.conda/envs/pytorch/lib/python3.8/site-packages/torch/functional.py", line 72, in broadcast_tensors
return _VF.broadcast_tensors(tensors) # type: ignore[attr-defined]
RuntimeError: The size of tensor a (32) must match the size of tensor b (40) at non-singleton dimension 2
大概意思应该是y_mel和y_g_hat_mel的张量维度不相同
2.断点调试
(batch_size=1)
3.分析:问题定位到generator.py中函数FreGAN()的返回值上
二.解决方法
1.upsample_rates的乘积要等于hopsize,修改config中的内容为:
upsample_rates: [5,5,2,2,2],upsample_kernel_sizes: [10,10,4,4,4]
2.上卷积的时候padding的问题导致最后的维度对不上,代码修改如下:
三.参考知乎网址
1.细读经典:HiFiGAN,拥有多尺度和多周期判别器的高效声码器
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)