Python 4D np.数据类型的数组';对象';使用数据类型为'的3D np.array;uint8';作为元素 类型(imgs):| -------- 形状| (40,) ------- imgs[0]。形状| (3, 512, 512) ------- imgs 255,255,255,255,255,255,255,255]],dtype=uint8]| 数据类型=对象) ------- imgs[0].dtype| 数据类型('uint8') ------- imgs.dtype| 数据类型('O') ------- imgs[39].数据类型| 数据类型('uint8')
我想将imgs格式化为一个4D np.dtype数组('uint8'),而不是一个1D np.dtype数组('Object'),其中每个元素都是一个3D np.dtype数组('uint8')。如果所有Python 4D np.数据类型的数组';对象';使用数据类型为'的3D np.array;uint8';作为元素 类型(imgs):| -------- 形状| (40,) ------- imgs[0]。形状| (3, 512, 512) ------- imgs 255,255,255,255,255,255,255,255]],dtype=uint8]| 数据类型=对象) ------- imgs[0].dtype| 数据类型('uint8') ------- imgs.dtype| 数据类型('O') ------- imgs[39].数据类型| 数据类型('uint8'),python,numpy,Python,Numpy,我想将imgs格式化为一个4D np.dtype数组('uint8'),而不是一个1D np.dtype数组('Object'),其中每个元素都是一个3D np.dtype数组('uint8')。如果所有imgs的元素具有相同的形状,np.stack(imgs)应该生成4D数组。如果imgs的所有元素具有相同的形状,np.stack(imgs)应该生成4d数组。 type(imgs):
imgs
的元素具有相同的形状,np.stack(imgs)
应该生成4D数组。如果imgs
的所有元素具有相同的形状,np.stack(imgs)
应该生成4d数组。
type(imgs): |
<class 'numpy.ndarray'>
--------
imgs.shape |
(40,)
-------
imgs[0].shape |
(3, 512, 512)
-------
imgs
255, 255, 255, 255, 255, 255, 255, 255]]], dtype=uint8)], |
dtype=object)
-------
imgs[0].dtype |
dtype('uint8')
-------
imgs.dtype |
dtype('O')
-------
imgs[39].dtype |
dtype('uint8')