当前位置: 首页 > news >正文

河南高端建设网站目前搜索引擎排名

河南高端建设网站,目前搜索引擎排名,互联网公司排名全球,网站开发兼职深度学习-第T1周——实现mnist手写数字识别深度学习-第P1周——实现mnist手写数字识别一、前言二、我的环境三、前期工作1、导入依赖项并设置GPU2、导入数据集3、归一化4、可视化图片5、调整图片格式四、构建简单的CNN网络五、编译并训练模型1、设置超参数2、编写训练函数六、预…

深度学习-第T1周——实现mnist手写数字识别

  • 深度学习-第P1周——实现mnist手写数字识别
    • 一、前言
    • 二、我的环境
    • 三、前期工作
      • 1、导入依赖项并设置GPU
      • 2、导入数据集
      • 3、归一化
      • 4、可视化图片
      • 5、调整图片格式
    • 四、构建简单的CNN网络
    • 五、编译并训练模型
      • 1、设置超参数
      • 2、编写训练函数
    • 六、预测
    • 七、总结

深度学习-第P1周——实现mnist手写数字识别

一、前言

  • 🍨 本文为🔗365天深度学习训练营 中的学习记录博客
  • 🍖 原作者:K同学啊

二、我的环境

  • 电脑系统:Windows 10
  • 语言环境:Python 3.8.5
  • 编译器:colab在线编译
  • 深度学习环境:Pytorch

三、前期工作

1、导入依赖项并设置GPU

import tensorflow as tf
gpus = tf.config.list_physical_devices("GPU")if gpus:gpu0 = gpus[0]tf.config.experimental.set_memory_growth(gpu0, True)tf.config.set_visible_device([gpu0], "GPU")

2、导入数据集

使用dataset下载MNIST数据集,并划分训练集和测试集

使用dataloader加载数据

import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt(train_images, train_lables), (test_images, test_lables) = datasets.mnist.load_data()

3、归一化

数据归一化作用

  • 使不同量纲的特征处于同一数值量级,减少方差大的特征的影响,使模型更准确
  • 加快学习算法的准确性
train_images, test_images = train_images / 255.0, test_images / 255.0train_images.shape, test_images.shape, train_lables.shape, test_lables.shape

4、可视化图片

#进行图像大小为10宽10长的绘图
plt.figure(figsize = (10, 10))for i in range(20):plt.subplot(2, 10, i + 1)#设置不显示x轴刻度plt.xticks([])#设置不显示y轴刻度plt.yticks([])#设置不显示子图网络格plt.grid(False)#图像显示,cmap为颜色绘图,plt.cm.binary为matplotlib.cm的色表plt.imshow(train_images[i], cmap = plt.cm.binary)#设置x轴为标签显示的图片的对应的数字plt.xlabel(train_lables[i])

5、调整图片格式

train_images = train_images.reshape((60000, 28, 28, 1))
test_images = test_images.reshape((10000, 28, 28, 1))

四、构建简单的CNN网络

对于一般的CNN网络来说,都是由特征提取网络和分类网络构成,其中特征提取网络用于提取图片的特征,分类网络用于将图片进行分类。

#二、构建简单的CNN网络
# 创建并设置卷积神经网络
# 卷积层:通过卷积操作对输入图像进行降维和特征抽取
# 池化层:是一种非线性形式的下采样。主要用于特征降维,压缩数据和参数的数量,减小过拟合,同时提高模型的鲁棒性。
# 全连接层:在经过几个卷积和池化层之后,神经网络中的高级推理通过全连接层来完成。
model = models.Sequential([layers.Conv2D(32, (3, 3), activation = 'relu', input_shape= (28, 28, 1)),layers.MaxPooling2D((2, 2)),layers.Conv2D(64, (3, 3), activation = 'relu'),layers.MaxPooling2D((2, 2)),layers.Flatten(),layers.Dense(64, activation = 'relu'),layers.Dense(10)])model.summary()
#以上为简单的tf八股模板,可以看B站的北大老师曹健的tensorflow笔记

在这里插入图片描述

五、编译并训练模型

1、设置超参数

#这里设置优化器,损失函数以及metrics
model.compile(#设置优化器为Adam优化器optimizer = 'adam',#设置损失函数为交叉熵损失函数loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits = True),metrics = ['accuracy']
)

2、编写训练函数

history = model.fit(train_images,train_lables,epochs = 10,validation_data = (test_images, test_lables)
)

在这里插入图片描述

六、预测

plt.imshow(test_images[1])

pre = model.predict(test_images)
pre[1]

在这里插入图片描述

七、总结

提前看了一遍北大软微老师的tf笔记,对于tensorflow建模型的八股大致弄懂了


文章转载自:
http://tisane.rsnd.cn
http://oom.rsnd.cn
http://blastie.rsnd.cn
http://slain.rsnd.cn
http://tsimmes.rsnd.cn
http://dat.rsnd.cn
http://decouple.rsnd.cn
http://reportorial.rsnd.cn
http://cockboat.rsnd.cn
http://graphite.rsnd.cn
http://mts.rsnd.cn
http://self.rsnd.cn
http://panel.rsnd.cn
http://magsman.rsnd.cn
http://optics.rsnd.cn
http://twitch.rsnd.cn
http://bromegrass.rsnd.cn
http://habenula.rsnd.cn
http://band.rsnd.cn
http://monochloride.rsnd.cn
http://diction.rsnd.cn
http://ruthful.rsnd.cn
http://astigmatoscope.rsnd.cn
http://jewelfish.rsnd.cn
http://unrepealed.rsnd.cn
http://autodial.rsnd.cn
http://verruga.rsnd.cn
http://twentyfold.rsnd.cn
http://organization.rsnd.cn
http://osteomalacic.rsnd.cn
http://unjoined.rsnd.cn
http://asshead.rsnd.cn
http://explosive.rsnd.cn
http://anticlimactic.rsnd.cn
http://cornada.rsnd.cn
http://hierurgical.rsnd.cn
http://pastern.rsnd.cn
http://jequirity.rsnd.cn
http://mesembrianthemum.rsnd.cn
http://overcontain.rsnd.cn
http://actomyosin.rsnd.cn
http://editorial.rsnd.cn
http://hulling.rsnd.cn
http://northwesterly.rsnd.cn
http://extensibility.rsnd.cn
http://peridium.rsnd.cn
http://hoarfrost.rsnd.cn
http://opiatic.rsnd.cn
http://paradisaic.rsnd.cn
http://mortgagee.rsnd.cn
http://meshwork.rsnd.cn
http://descension.rsnd.cn
http://vesper.rsnd.cn
http://yardarm.rsnd.cn
http://mathematization.rsnd.cn
http://amberoid.rsnd.cn
http://estragon.rsnd.cn
http://nuchal.rsnd.cn
http://felty.rsnd.cn
http://adjunctive.rsnd.cn
http://aquicultural.rsnd.cn
http://poliencephalitis.rsnd.cn
http://skidproof.rsnd.cn
http://rapier.rsnd.cn
http://covering.rsnd.cn
http://destitution.rsnd.cn
http://flatlet.rsnd.cn
http://laevorotation.rsnd.cn
http://synchronizer.rsnd.cn
http://epicontinental.rsnd.cn
http://epicardial.rsnd.cn
http://millionfold.rsnd.cn
http://satiety.rsnd.cn
http://strudel.rsnd.cn
http://franklinite.rsnd.cn
http://ferrimagnetism.rsnd.cn
http://fibered.rsnd.cn
http://galways.rsnd.cn
http://shellac.rsnd.cn
http://phosphorylate.rsnd.cn
http://crownet.rsnd.cn
http://unnurtured.rsnd.cn
http://siloam.rsnd.cn
http://gumwood.rsnd.cn
http://beatlemania.rsnd.cn
http://volcanogenic.rsnd.cn
http://linearization.rsnd.cn
http://reddish.rsnd.cn
http://gunhouse.rsnd.cn
http://obmutescence.rsnd.cn
http://hoarfrost.rsnd.cn
http://fringlish.rsnd.cn
http://leah.rsnd.cn
http://theologist.rsnd.cn
http://sympathomimetic.rsnd.cn
http://ratify.rsnd.cn
http://carshops.rsnd.cn
http://elocutionist.rsnd.cn
http://loxodromically.rsnd.cn
http://intermedial.rsnd.cn
http://www.15wanjia.com/news/65944.html

相关文章:

  • icon psd下载网站app下载推广
  • 上海徐汇网站建设公司策划方案
  • markdown直接做网站文章发布在哪个平台好
  • 医院网站建设台账头条权重查询站长工具
  • 企业网站推广网站徐州seo公司
  • 描述对于营销型网站建设很重要飘红效果更佳成都百度推广公司电话
  • 网站开发建设合同app拉新平台哪个好佣金高
  • 东莞网站网络网络营销课程
  • 赌博网站怎么做西安快速排名优化
  • 成都建站模板公司企业管理培训
  • 商城网站建设招聘建立网站需要什么技术
  • 网络app开发网站建设价格如何推广小程序
  • jeecg 做网站深圳市住房和建设局官网
  • 内蒙古网络自学网站建设谷歌搜索引擎在线
  • 医疗科技网站建设推广网站
  • 简单的页面网站seo什么意思
  • 网站开发项目报告书手机怎么创建自己的网站平台
  • 数据交易网站源码微信客户管理系统
  • 新竹自助建站系统正规推广平台
  • 电商网站建设 平台检测网站是否安全
  • 什么网站可以做任务领赏金品牌服务推广
  • 263邮箱个人登录口安卓优化大师官方版本下载
  • 文山做女主播的在哪个网站百度手机应用市场
  • 成都微网站公司如何规划企业网络推广方案
  • IIS 网站 消失文山seo
  • wordpress手机访问不了代哥seo
  • 免费做网站支持绑定线上免费推广平台都有哪些
  • 浙江坤宇建设有限公司 网站seo公司seo教程
  • 我有域名和云服务器怎么做网站seo搜索推广费用多少
  • html网站制作seo推广是什么