Skip to content

Instantly share code, notes, and snippets.

@candlewill
Last active July 21, 2020 09:07
Show Gist options
  • Save candlewill/2eadda3761dc0de62102696c4ba718b2 to your computer and use it in GitHub Desktop.
Save candlewill/2eadda3761dc0de62102696c4ba718b2 to your computer and use it in GitHub Desktop.
Some tips for using tf.data dataset

Some tips for using tf.data dataset

Pipelines:

  1. Create a source dataset from input data
  2. Apply dataset transformations
  3. Iterate overt the dataset

Methods for create a dataset:

  • tf.data.Dataset.from_tensor_slices
  • tf.data.TextLineDataset
  • tf.data.TFRecordDataset
  • tf.data.Dataset.list_files
  • tf.data.Dataset.from_generator
  • tf.data.Dataset.from_tensors

Methods for dataset transformations

  • map
  • apply
  • as_numpy_iterator
  • batch
  • cache
  • concatenate
  • enumerate
  • interleave
  • filter
  • flat_map := map and flatten
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment