训练模型时报错:
TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:
* (tuple of ints size, *, tuple of names names, torch.memory_format memory_format, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
* (tuple of SymInts size, *, torch.memory_format memory_format, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
解决:确保num_classes是int,且检查构建卷积时的参数,要求为int整型
model = SoundNet(num_classes=10)
注意⚠️:若构建卷积时的参数有除法,python3中两个int整型相除得到的是float浮点型,将其转化为int型即可~