Python 关于float对象的错误消息,不能解释为整数

Python 关于float对象的错误消息,不能解释为整数,python,python-3.x,numpy,scipy,Python,Python 3.x,Numpy,Scipy,我使用下面的代码行定义一个多维数组,以保存一组表示为二维数组的图像 import numpy as np imgs = np.ndarray((100, 1, image_rows, image_cols), dtype=np.float32) 这里,100表示总共有100个图像。 但是,运行该程序会出现以下错误消息TypeError:“float”对象不能解释为整数。这意味着什么以及如何解决它?如果image\u行或image\u列是浮点值,则会出现该错误: In [15]: imgs

我使用下面的代码行定义一个多维数组,以保存一组表示为二维数组的图像

 import numpy as np
 imgs = np.ndarray((100, 1, image_rows, image_cols), dtype=np.float32)
这里,
100
表示总共有100个图像。
但是,运行该程序会出现以下错误消息
TypeError:“float”对象不能解释为整数。这意味着什么以及如何解决它?

如果
image\u行
image\u列
是浮点值,则会出现该错误:

In [15]: imgs = np.ndarray((100, 1, 5.0, 10.0), dtype=np.float32)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-c7783d157b42> in <module>()
----> 1 imgs = np.ndarray((100, 1, 5.0, 10.0), dtype=np.float32)

TypeError: 'float' object cannot be interpreted as an integer

image\u行
image\u列
int吗?
imgs = np.ndarray((100, 1, int(image_rows), int(image_cols)), dtype=np.float32)