0

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

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

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.

8
  • 1
    np.concatenate(alist, axis=0) should work. Don't do this in a loop - collect a list of all the array, and do one concatenate. Forget about np.append. Commented Jun 25, 2018 at 6:10
  • What's alist here? Commented Jun 25, 2018 at 6:11
  • alist of all the arrays you want to join! Commented Jun 25, 2018 at 6:12
  • np.concatenate([a,b,c,d],axis=0) gives me ValueError: all the input arrays must have same number of dimension, ----- and the shapes are (1500, 227, 227, 3) (1500, 227, 227, 3) (0,) (1380, 227, 227, 3) Commented Jun 25, 2018 at 6:25
  • 1
    The (0,) does not have the same number of dimensions as the others. Commented Jun 25, 2018 at 6:30

1 Answer 1

0

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) works.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.