Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 56 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import tensorflow as tf
  2. import tensorflow_datasets as tfds
  3.  
  4. # tfds works with Eager and Graph modes
  5. tf.enable_eager_execution()
  6.  
  7. # 0. Select the dataset you'd like to use
  8. print(tfds.list_builders())
  9.  
  10. # 1. Construct the DatasetBuilder
  11. #    Each dataset is implemented as a DatasetBuilder and can be fetched by
  12. #    string name.
  13. mnist_builder = tfds.builder(name="mnist", data_dir="~/tfds/data")
  14.  
  15. # 2. Download and prepare the dataset into a format ready for a tf.data pipeline
  16. mnist_builder.download_and_prepare()
  17.  
  18. # 3. Build a tf.data.Dataset from the prepared data
  19. train_dataset = mnist_builder.as_dataset(split=tfds.Split.TRAIN)
  20.  
  21. # 4. Build the rest of your input pipeline using the tf.data API
  22. train_dataset = train_dataset.repeat().shuffle(1024).batch(32).prefetch(100)
  23.  
  24. # If we looked at a single batch, it has a features dictionary with keys
  25. # "input" and "target"
  26. features, = train_dataset.take(1)
  27. images, labels = features["input"], features["target"]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top