TypeError: ‘numpy.float64‘ object cannot be interpreted as an integer类型出错

TypeError: ‘numpy.float64’ object cannot be interpreted as an integer

出错代码:
    for i in range(overlap_ranges.shape[1]):
        for j in range(overlap_ranges.shape[2]):
            min_overlaps[:, i, j] = np.linspace(*overlap_ranges[:, i, j])

输入:overlap_ranges为np.array([[[0.5], [0.5], [0.5]], [[0.95], [0.95], [0.95]], [[10], [10], [10]]])

出错原因:
  • 本地numpy版本1.17.2,支持np.linspace(0.5,0.95,10.0)最后一位作为np.float64输入,正常运行。
  • 服务器numpy版本1.19.1,不支持np.linspace浮点数作为最后一个参数。
解决方法:

降维打击,高版本numpy降维:

   pip install -U numpy==1.17.2

猜你喜欢

转载自blog.csdn.net/qq_41870658/article/details/108417736