在机器学习 tensorflow 2 的hello world 一文里,介绍了一个最简单的tensorflow 2编程。本文就在其的基础上,来个实际的例子:图像分类。
总共包含10个类别中的70,000个灰度图像。使用60,000张图像来训练网络,用10,000张图像让机器判断,以评估网络学习图像分类的准确程度。当然这些图像都是现成提供,用于我们学习。
原始的代码和教程
英文:https://tensorflow.google.cn/tutorials/keras/classification
中文:https://blog.youkuaiyun.com/qq_20084101/article/details/81984312
1:下载数据
在程序开头,我们包含基本包,显示版本号。
然后fashion_mnist = keras.datasets.fashion_mnist 准备下载 Fashion MNIST库里的数据
下面(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
这个语句导入数据库里的数据到 (train_images, train_labels), (test_images, test_labels)
图像images(train_images,test_images)是28x28 NumPy数组,像素值介于0到255之间。
标签labels(train_la