I have two numpy arrays named my_arr1, my_arr2
both of them of size 100x30x30x3
. I would like to output the combination of each row of the first array with each row from the second array and result to two new arrays with size 10000x30x30x3
. I managed to do so with a simpler example with two array of size 4x2
by following that example:
a1_ = np.array([[1, 1],
[2, 2],
[3, 0],
[4, 2],
[5, 3]])
a2_ = np.array([[10, 1],
[11, 2],
[12, 0],
[13, 2],
[14, 3]])
def combine_matrices(a1, a2):
m1, n1 = a1.shape
m2, n2 = a2.shape
out = np.zeros((m1, m2, n1+n2), dtype=int)
out[:, :, :n1] = a1[:, None, :]
out[:, :, n1:] = a2
out.shape = (m1*m2, -1)
return out
The reult is a 25x4
array which can be split to two arrays 25x2
. How can I modify my function in case that a1 = np.zeros((100, 30, 30, 3))
and a2 = np.zeros((100. 30, 30, 3))
with final scope to return two arrays with size (10000, 30, 30 ,3)
and not just one.