import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('./data/mnist_data', one_hot=True)
i = 0
# 获取图片
image = mnist.train.images[i]
# 将图像数据还原成28*28的分辨率
image = image.reshape(28, 28)
# 打印对应的标签
answer = np.argmax(mnist.train.labels[i])
plt.imshow(image,cmap='binary')
title = 'No.'+str(i-int('0'))+': '+str(answer-int('0'))
plt.title(title)
plt.show()
MNIST用matplotlib实现可视化
最新推荐文章于 2025-03-12 10:00:00 发布
本文通过使用TensorFlow读取MNIST数据集,并利用Matplotlib进行图像展示,实现了对MNIST手写数字数据集的可视化。文章展示了如何从数据集中获取一张图片,将其还原为28x28像素的分辨率,并打印出对应的标签。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.9
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型
2247

被折叠的 条评论
为什么被折叠?



