這個問題是小虎在初始化自適應(yīng)平均池化的時候遇到的,解決方法是限制初始化時池化大小的類型。
問題原文
Exception has occurred: TypeError
object of type 'numpy.int64' has no len()
File "D:\Complier\LEF\lib\model\segmentation\heads\modules\fgModules.py", line 162, in forward
PoolFeature = callMethod(self, Name)(self.PoolLayer(f))
TypeError: object of type 'numpy.int64' has no len()
解決實例
報錯語句如下:
AdaptiveAvgPool2d(self.PoolSize)
查看類型發(fā)現(xiàn)是numpy:文章來源:http://www.zghlxwxcb.cn/news/detail-738235.html
type(self.PoolSize)
<class 'numpy.int64'>
所以可以改成:文章來源地址http://www.zghlxwxcb.cn/news/detail-738235.html
AdaptiveAvgPool2d(int(self.PoolSize))
到了這里,關(guān)于親測解決Pytorch TypeError: object of type ‘numpy.int64‘ has no len()的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!