[SOLVED] Numpy.concatenate

I’m trying to concatenate 2 numpy arrays of features predicted by the convolution layers in a vgg16 model.

Basically i have used the bottom layers of a vgg16 model to predict the features for my full dataset and now I want to load the parts of dataset dynamically based on some settings from a dict, to train some models with it.

So, I have 2 array of shape:
(724, 512, 6, 8) and (3376, 512, 6, 8)
Basically the first one contains features predicted from 724 image files (each prediction has shape (512, 6, 8)).
I want to concatenate these 2 arrays into one of shape (4100, 512, 6, 8)

I have tried using:
np.array([np.concatenate(arr, axis=0) for arr in false_train_list])
where false_train_list is the list containing the 2 arrays with the above shapes.

Also tried with np.stack, tf.stack, etc…
All of these result in an array with shape (2,)

Can someone explain why ? I haven’t found any good resources to understand how exactly np.concatenate() works…

Thank you!

I don’t know If I completely understood your problem but I can do the following:

import numpy as np
foo = np.random.rand(10, 5, 4, 3)
bar = np.random.rand(12, 5, 4, 3)
res = np.concatenate((foo, bar), axis = 0)

res.shape -> (22, 5, 4, 3)

Solved using np.concatenate(–list containing my arrays–, axis=0);