How can I fix this error : Python Error ""ValueError: could not broadcast input array from shape (4) into shape (1000)""
Your data generator retrieves your labels as categorical and based on the error, I assume you have 4 classes. However, in your extract_features function, you are first initializing a labels array of shape=(sample_count) instead of shape=(sample_count, 4). In your for loop, you are getting a labels_batch from the generator which apparently has a shape of (16, 4) and you are trying to save it as part of your initialized labels array which has a shape of (sample_count) instead of (sample_count, 4) and that's why it complains.

In short, you should change:

labels = np.zeros(shape=(sample_count))


to:

labels = np.zeros(shape=(sample_count, 4))