1

If I had two Numpy arrays: both with shape (50,5,5) how would I add both of them to get an array with (50,5,10)?

2 Answers 2

3

Use concatenate:

import numpy as np
n = 50 * 5 * 5
a = np.random.random(size=n).reshape(50,5,5)
b = np.random.random(size=n).reshape(50,5,5)

np.concatenate([a,b], axis=2).shape # (50, 5, 10)
Sign up to request clarification or add additional context in comments.

Comments

0

numpy.dstack would do the trick

import numpy
In[2]: out_array = numpy.dstack([numpy.empty((50, 5, 5)), numpy.empty((50, 5, 5))])
In[3]: out_array.shape
Out[3]: (50L, 5L, 10L)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.