当前位置:首页 > 编程笔记 > 正文
已解决

亲测解决Pytorch TypeError: object of type ‘numpy.int64‘ has no len()

来自网友在路上 160860提问 提问时间:2023-11-02 16:35:25阅读次数: 60

最佳答案 问答题库608位专家为你答疑解惑

这个问题是小虎在初始化自适应平均池化的时候遇到的,解决方法是限制初始化时池化大小的类型。

问题原文

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 forwardPoolFeature = callMethod(self, Name)(self.PoolLayer(f))
TypeError: object of type 'numpy.int64' has no len()

解决实例

报错语句如下:

AdaptiveAvgPool2d(self.PoolSize)

查看类型发现是numpy:

type(self.PoolSize)
<class 'numpy.int64'>

所以可以改成:

AdaptiveAvgPool2d(int(self.PoolSize))
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"亲测解决Pytorch TypeError: object of type ‘numpy.int64‘ has no len()":http://eshow365.cn/6-30337-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!