extending the model you have (conv_baseby adding dense layers on topand running the whole thing end to end on the input data this will allow you to use data augmentationbecause every input image goes through the convolutional base every time it' seen by the model but for the same reasonthis technique is far more expensive than the first we'll cover both techniques let' walk through the code required to set up the first onerecording the output of conv_base on your data and using these outputs as inputs to new model fast feature extraction without data augmentation you'll start by running instances of the previously introduced imagedatagenerator to extract images as numpy arrays as well as their labels you'll extract features from these images by calling the predict method of the conv_base model listing ext ract ing feat ures using he pretrained convolut ional base import os import numpy as np from keras preprocessing image import imagedatagenerator base_dir '/users/fchollet/downloads/cats_and_dogs_smalltrain_dir os path join(base_dir'train'validation_dir os path join(base_dir'validation'test_dir os path join(base_dir'test'datagen imagedatagenerator(rescale= / batch_size def extract_features(directorysample_count)features np zeros(shape=(sample_count )labels np zeros(shape=(sample_count)generator datagen flow_from_directorynote that because generators directoryyield data indefinitely in looptarget_size=( )you must break after every batch_size=batch_sizeimage has been seen once class_mode='binary' for inputs_batchlabels_batch in generatorfeatures_batch conv_base predict(inputs_batchfeatures[ batch_size ( batch_sizefeatures_batch labels[ batch_size ( batch_sizelabels_batch + if batch_size >sample_countbreak return featureslabels train_featurestrain_labels extract_features(train_dir validation_featuresvalidation_labels extract_features(validation_dir test_featurestest_labels extract_features(test_dir the extracted features are currently of shape (samples you'll feed them to densely connected classifierso first you must flatten them to (samples )licensed to