{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "gQskE9NgL-ZB" }, "source": [ "Copyright 2018 The TensorFlow Datasets Authors, Licensed under the Apache License, Version 2.0" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "RPo1Cw2p83pb" }, "outputs": [], "source": [ "!pip install -q nlp tensorflow" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "S-RWB9G48uJA" }, "outputs": [], "source": [ "from __future__ import absolute_import\n", "from __future__ import division\n", "from __future__ import print_function\n", "\n", "import tensorflow.compat.v2 as tf\n", "import nlp\n", "\n", "# nlp works in both Eager and Graph modes\n", "tf.enable_v2_behavior()\n", "\n", "# Construct a tf.data.Dataset\n", "ds = nlp.load('mnist', split='train', shuffle_files=True)\n", "\n", "# Build your input pipeline\n", "ds = ds.shuffle(1024).batch(32).prefetch(tf.data.experimental.AUTOTUNE)\n", "for example in ds.take(1):\n", " image, label = example['image'], example['label']" ] } ], "metadata": { "colab": { "collapsed_sections": [], "name": "tensorflow/datasets", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 0 }