tensorflow2.0 公共训练数据加载的两个方法

学习笔记:训练数据加载

方法一:通过tensorflow.keras.datasets加载

from tensorflow import keras

#加载fashion_mnist(时装图片)数据
(x_train, y_train), (x_test, y_test) = keras.datasets.fashion_mnist.load_data()

#加载mnist(手写数字)数据
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()

方法一:通过tensorflow_datasets模块加载

首先python需要安装tensorflow_datasets模块

pip install tensorflow_datasets

然后程序代码:

import tensorflow_datasets as tfds

#加载fashion_mnist(时装图片)数据
dataset, metadata =tfds.load('fashion_mnist', as_supervised = True, with_info = True)

#加载mnist(手写数字)数据
dataset, metadata =tfds.load('mnist', as_supervised = True, with_info = True)

dataset_train, dataset_test = dataset['train'], dataset['test']

 

你可能感兴趣的:(tensorflow,Python)