如何使用 TensorFlow 和 Python 验证 CIFAR 数据集?
CIFAR 数据集可以通过在控制台上绘制数据集中的图像来验证。由于 CIFAR 标签是数组,因此需要额外的索引。'matplotlib' 库中的 'imshow' 方法用于显示图像。
阅读更多: 什么是 TensorFlow 以及 Keras 如何与 TensorFlow 协同工作以创建神经网络?
我们正在使用 Google Colaboratory 来运行以下代码。Google Colab 或 Colaboratory 帮助在浏览器上运行 Python 代码,无需任何配置,并且可以免费访问 GPU(图形处理单元)。Colaboratory 建立在 Jupyter Notebook 之上。
print("Verifying the data")
plt.figure(figsize=(10,10))
print("Plot the first 15 images")
print("An extra index is needed since CIFAR labels are arrays")
for i in range(15):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[train_labels[i][0]])
plt.show()代码来源:https://tensorflowcn.cn/tutorials/images/cnn
输出
Verifying the data Plot the first 15 images An extra index is needed since CIFAR labels are arrays
解释
- 可视化已标准化的数据。
- 这是使用 'matplotlib' 库完成的。
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP