TensorFlow I/O extends TensorFlow with filesystem and file-format integrations, allowing datasets to enter tf.Dataset pipelines without first being fully copied into memory. This avoids GraphDef size limits and reduces memory or disk pressure for larger datasets. section 2.3.2
Use TensorFlow I/O when dataset storage or scale makes direct in-memory loading impractical:
- Load MNIST files directly from a URL through HTTP filesystem support. section 2.3.2
- Read selected data from PostgreSQL through an IODataset SQL API. section 2.3.2
- Feed batches incrementally to model training instead of materializing the complete dataset. section 2.3.2
Loading data from external storage
Import tensorflow_io as tfio, then create an IODataset from MNIST URLs or a PostgreSQL query. The resulting dataset exposes TensorFlow element specifications for downstream training. section 2.3.2
Listing 2.3 Loading the MNIST dataset with TensorFlow I/O
> import tensorflow_io as tfio #1
>
> d_train = tfio.IODataset.from_mnist( #2
'http:/ /yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz',
'http:/ /yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz')
Inspect the concrete MNIST URL-loading call and its two input files. section 2.3.2
