本文介绍了numpy连接多个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多形状为(Ni,227,227,3)的numpy数组,其中每个数组的Ni都不同.

I have many numpy arrays of shape (Ni,227,227,3), where Ni of each array is different.

我想加入它们并制作形状为(N1 + N2 + .. + Nk,227,227,3)的阵列,其中k是阵列数.

I want to join them and make array of shape (N1+N2+..+Nk,227,227,3) where k is the number of arrays.

我尝试了numpy.concatenate和numpy.append,但它们在轴0上要求相同的尺寸.我也对数组中的轴1和轴2感到困惑.

I tried numpy.concatenate and numpy.append but they ask for same dimension in axis 0. I am also confused on what is axis 1 and axis 2 in my arrays.

推荐答案

因此,这里的主要问题是形状为(0,)而不是(0,227,227,3)的数组之一.

So, the main problem here was with the one of the arrays of shape (0,) instead of (0,227,227,3).

np.concatenate(alist,axis = 0)有效.

np.concatenate(alist,axis=0) works.

这篇关于numpy连接多个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 10:08