Skip to content

Instantly share code, notes, and snippets.

@jkmackie
Last active September 21, 2022 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkmackie/67b69dbeb7a23e11fe1cf55670ad5dfd to your computer and use it in GitHub Desktop.
Save jkmackie/67b69dbeb7a23e11fe1cf55670ad5dfd to your computer and use it in GitHub Desktop.
#Preprocess dataset per https://www.tensorflow.org/tutorials/load_data/images
train_ds = train_ds.map(lambda x, y: (preprocess_input(x), y))
val_ds = val_ds.map(lambda x, y: (preprocess_input(x), y))
# Show min/max of first image. Notice the pixel values after preprocess.
image_batch, labels_batch = next(iter(train_ds))
first_image = image_batch[0]
print('image min and max values:', np.min(first_image), np.max(first_image), '\n\n')
# Load and freeze VGG16 model.
# Include_top=False removes classification layer trained on ImageNet.
base_model = VGG16(weights="imagenet", include_top=False, input_shape=(224,224,3))
base_model.trainable = False ## Not trainable weights
base_model.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment