Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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 3.x 如何将一个小数组复制到一个大数组上?_Python 3.x_Numpy_Numpy Ndarray - Fatal编程技术网

Python 3.x 如何将一个小数组复制到一个大数组上?

Python 3.x 如何将一个小数组复制到一个大数组上?,python-3.x,numpy,numpy-ndarray,Python 3.x,Numpy,Numpy Ndarray,我正在尝试将一个大小为(829,1)的小numpy ndarray复制到一个大小为(3047,1)的大numpy ndarray上 我的代码如下 highest = 3047 features = loadmat(f"./{file}.sbow.mat") current_features = np.zeros((highest, 1), dtype=int) print(type(current_features)) print(type(features["im

我正在尝试将一个大小为(829,1)的小numpy ndarray复制到一个大小为(3047,1)的大numpy ndarray上

我的代码如下

highest = 3047
features = loadmat(f"./{file}.sbow.mat")
current_features = np.zeros((highest, 1), dtype=int)
print(type(current_features))
print(type(features["image_sbow"]))
print(current_features.shape)
print(features["image_sbow"].shape)
current_features[:features["image_sbow"].shape[0], :1] = features["image_sbow"]
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
(3047, 1)
(829, 1)
我得到的输出如下所示

highest = 3047
features = loadmat(f"./{file}.sbow.mat")
current_features = np.zeros((highest, 1), dtype=int)
print(type(current_features))
print(type(features["image_sbow"]))
print(current_features.shape)
print(features["image_sbow"].shape)
current_features[:features["image_sbow"].shape[0], :1] = features["image_sbow"]
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
(3047, 1)
(829, 1)

(3047, 1)
(829, 1)
下面给出了我得到的错误

highest = 3047
features = loadmat(f"./{file}.sbow.mat")
current_features = np.zeros((highest, 1), dtype=int)
print(type(current_features))
print(type(features["image_sbow"]))
print(current_features.shape)
print(features["image_sbow"].shape)
current_features[:features["image_sbow"].shape[0], :1] = features["image_sbow"]
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
(3047, 1)
(829, 1)
ValueError:无法从结构强制转换为非结构,除非 结构只有一个字段


您需要更详细地检查
功能[“image\u show”]
数组,而不仅仅是
类型
形状
数据类型是什么。根据这个错误,我认为它不是
int
。这是更复杂的事情。