Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
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 - Fatal编程技术网

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 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格式化为一个4D np.dtype数组('uint8'),而不是一个1D np.dtype数组('Object'),其中每个元素都是一个3D np.dtype数组('uint8')。

如果所有
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')