原文来自TensorFlow官网教程,讲的很详细,对于我这等铁five来说,真的很有用,害怕忘掉,赶紧记下来。
原文网址:https://tensorflow.google.cn/tutorials/keras/classification
本指南训练了一个神经网络模型来对运动鞋和衬衫等服装的图像进行分类。如果您不了解所有细节,也可以;这是完整的TensorFlow程序的快速概述,详细内容随您进行。
本指南使用tf.keras(高级API)在TensorFlow中构建和训练模型。
# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras
# Helper libraries
import numpy as np
import matplotlib.pyplot as plt
print(tf.__version__)
2.3.0
导入Fashion MNIST数据集
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
加载数据集将返回四个NumPy数组:
- 在
train_images
和tra