I am creating inside a for loop in each iteration of it a numpy array of size 20x30x30x3. I want to concatenate all of those numpy arrays into a bigger one. If the iteration steps are 100 then the numpy array I want should be2000x30x30x3. I tried to do with lists:
new_one_arr1_list = []
new_one_arr2_list = []
all_arr1 = np.array([])
for item in one_arr1: # 100 iterations
item = np.reshape(item, (1, 30, 30, 3))
new_one_arr1 = np.repeat(item, 20, axis=0)
all_arr1 = np.concatenate(([all_arr1 , new_one_arr1 ]))
ind = np.random.randint(one_arr2.shape[0], size=(20,))
new_one_arr2= one_arr1[ind]
new_one_arr1_list.append(new_one_arr1)
new_one_arr2_list.append(new_one_arr2)
In each iteration step new_one_arr1 and new_one_arr2 they have size 20x30x30x3. In the end when I am converting new_one_arr1_list and new_one_arr2_list and the size it is 100x20x30x30x3. How can I have 2000x30x30x3 in the end in a numpy array?
EDIT: I tried to use concatenate to add the arrays within a numpy array all_arr1 using: all_arr1= np.concatenate(([all_arr1, new_one_arr1])) however, I received the message:
ValueError: all the input arrays must have same number of dimensions
//for comment instead of#. This code can't compile.