日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

【深度学习】empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=None

發布時間:2025/3/15 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【深度学习】empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=None 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

構建yoloV3的resblock時,python的一個小坑

在構建一個簡單的卷積層時,出現如下的錯誤:

代碼如下:

class resblock(nn.Module):def __init__(self,inputDims):super(resblock,self).__init__()self.inputChannels = inputDimsself.middleChannels = int(inputDims/2)#報錯行self.conv1 = nn.Conv2d(in_channels=inputDims,out_channels=inputDims/2,kernel_size=1,stride=1)self.bn1 = nn.BatchNorm2d(self.middleChannels)self.active1 = nn.LeakyReLU()self.conv3x3 = nn.Conv2d(in_channels=self.middleChannels,out_channels=inputDims,kernel_size=3,stride=1,padding=1)self.bn2 = nn.BatchNorm2d(inputDims)self.active2 = nn.LeakyReLU()self.shortcut = shortCut()def forward(self,x):y1 = self.active1(self.bn1(self.conv1(x)))y = self.active2(self.bn2(self.conv3x3(y1)))return self.shortcut(x,y)

產生的原因是因為在python3中兩個整型相除得到的是浮點型,例如:4/2=2.0,而在構建卷積時的參數要求時整型

總結

以上是生活随笔為你收集整理的【深度学习】empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=None的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。