Skip to content

Instantly share code, notes, and snippets.

@himanshurawlani
Last active December 31, 2023 00:14
Show Gist options
  • Save himanshurawlani/b94a750ee83e81a70814d117d65b097b to your computer and use it in GitHub Desktop.
Save himanshurawlani/b94a750ee83e81a70814d117d65b097b to your computer and use it in GitHub Desktop.
Pre-processing the dataset download using tfds.load()
def format_example(image, label):
image = tf.cast(image, tf.float32)
# Normalize the pixel values
image = image / 255.0
# Resize the image
image = tf.image.resize(image, (IMG_SIZE, IMG_SIZE))
return image, label
train = raw_train.map(format_example)
validation = raw_validation.map(format_example)
test = raw_test.map(format_example)
@brutalmaths
Copy link

Thank u

@kevencarneiro
Copy link

kevencarneiro commented Nov 22, 2021

Its worth to mention that you should load your dataset with tfds.load(..., as_supervised=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment