MNIST 手写数字识别调用

应用于Tensorflow2.7的,具体结果如图:

 数字图片显示:

 具体的代码:

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
%matplotlib inline 

print("Tensorflow version:", tf.__version__)

 文件下载的代码:

mnist =tf.keras.datasets.mnist
(train_images,train_labels),(test_images,test_labels)= mnist.load_data()
print("Train image shape:",train_images.shape,"Train label shape:",train_labels.shape)
print("Test image shape:",test_images.shape,"Test label shape:",test_labels.shape)
print("image data:",train_images[1])
print("train labels:",train_labels[1])

数字图片函数定义及实现代码:

def plot_image(image):
    plt.imshow(image.reshape(28,28),cmap='binary')
    plt.show()

选择train_image[]的可以正常显示图片。

imshow 的图片格式变换信息可以参考:Matplotlib imshow()函数_叫我SKY的博客-CSDN博客_plt.imshow()https://blog.csdn.net/qq_21763381/article/details/100169288

 (1条消息) 关于MNIST手写数字识别的几种实现方式_Lzjusc2017的博客-CSDN博客_手写数字识别mnisthttps://blog.csdn.net/qq_40318498/article/details/103071141

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值