训练模型时报错:
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整型文章来源:https://www.toymoban.com/news/detail-614776.html
model = SoundNet(num_classes=10)
注意⚠️:若构建卷积时的参数有除法,python3中两个int整型相除得到的是float浮点型,将其转化为int型即可~文章来源地址https://www.toymoban.com/news/detail-614776.html
到了这里,关于TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!