Hi All, this is a series of blogs that I intend to write about how to use TensorFlow 2.0 for deep learning.

大家好,我打算撰写一系列博客,介绍如何使用TensorFlow 2.0进行深度学习。

In this blog, I will go over how to classify Fashion Mnist data set using TensorFlow 2.0. Last time in Part1 we used a simple Dense model to classify these images. In this blog Part2, we are going to use Conv2D layers for this task. Again the idea is still the same, using TensorFlow 2.0 inbuilt layers to show how easy it is to use Conv2D layers along with MaxPooling2D layer to show how the classification model can be improved from the prior dense model.

在此博客中,我将介绍如何使用TensorFlow 2.0对Fashion Mnist数据集进行分类。 上一次在Part1中,我们使用了一个简单的Dense模型对这些图像进行分类。 在此博客第2部分中,我们将使用Conv2D图层来完成此任务。 再次,想法仍然是相同的,使用TensorFlow 2.0内置层来展示将Conv2D层与MaxPooling2D层一起使用是多么容易,以展示如何从先前的密集模型中改进分类模型。

Using the same template as we did before, here are five steps to run this classification.

使用与之前相同的模板,下面是执行此分类的五个步骤。

1. Dataset: Load the data set, do some feature engineering if needed.2. Build Model: Build a TensorFlow model with various layers.3. Compile Model: Here we compile the model, select the loss & Optimizer functions.4. Fit Model: Here we finally train the model using the training data and get some metrics.5. Evaluate Model: We check our model performance on the validation data.

1. 数据集:加载数据集,必要时进行一些功能设计。 构建模型:构建具有不同层的TensorFlow模型3。 编译模型:这里我们编译模型,选择损失和优化器功能。4。 拟合模型:在这里,我们最终使用训练数据来训练模型并获得一些指标。5。 评估模型:我们根据验证数据检查模型性能。

Dataset:This part remains the same as part1, as we are still using the same dataset. Fashion Minst: This is a dataset of 70,000 images. These are small grey scaled images with a standard size of 28x28 pixels. Here are a few examples.

数据集:该部分与part1相同,因为我们仍在使用相同的数据集。 Fashion Minst:这是一个包含70,000张图像的数据集。 这些是标准尺寸为28x28像素的小型灰度图像。 这里有一些例子。

First, let’s look at how to load data. This is going to use TensorFlow Datasets to do this.

首先,让我们看一下如何加载数据。 这将使用TensorFlow数据集来做到这一点。

#Importsimport tensorflow as tfimport tensorflow.keras as kerasfrom tensorflow.keras.models import Sequentialfrom tensorflow.keras.layers import Flatten,Conv2D,MaxPool2D,Dense#Load Datasetmnist = tf.keras.datasets.fashion_mnist(training_images, training_labels), (test_images, test_labels) =    fashion_mnist.load_data()#Reshape & Scaletraining_images=training_images.reshape(60000, 28, 28, 1)training_images=training_images / 255.0test_images = test_images.reshape(10000, 28, 28, 1)test_images=test_images/255.0

As you can see this function loads all the 70k images and splits it into two parts 60k for training and 10k for testing.

如您所见,此功能将加载所有70k图像,并将其分为两部分:60k用于训练,10k用于测试。

Build Model:

构建模型:

model= Sequential([                  Conv2D(16,(3,3),input_shape(28,28,1),                         activation='relu'),                  MaxPool2D(2,2),                  Flatten(),                  Dense(512,activation='relu'),                  Dense(10,activation='softmax')                 ])

This is the updated model using Conv2D layer and MaxPooling2D layer. To get a little bit more into the details:

这是使用Conv2D层和MaxPooling2D层的更新模型。 要进一步了解细节:

# Here is the model summary:model.summary()

Conv2D: This convolution layer can be thought of as matrix multiplication using the kernel size matrix in our example (3,3) so if our input size of the image is (28,28) our first Conv2D output would be a matrix of (28–3+1,28–3+1) so (26,26). We also have this process run for each filter so in our example of 16 filters the end dimensions are (26,26,16).

Conv2D:在我们的示例(3,3)中,可以使用内核大小矩阵将此卷积层视为矩阵乘法,因此,如果我们图像的输入大小为(28,28),则我们的第一个Conv2D输出将是(28)的矩阵–3 + 1,28–3 + 1)如此(26,26)。 我们还为每个过滤器运行此过程,因此在我们的16个过滤器示例中,最终尺寸为(26,26,16)。

MaxPooling2D: After this Con2D layer, we use MaxPooling2D that dimensions are reduced to (13,13,16) when we use the unit size of (2,2) after the above layer.

MaxPooling2D:在此Con2D层之后,我们使用MaxPooling2D,当我们在上一层之后使用(2,2)的单位大小时,尺寸减小到(13,13,16)。

One more new parameter we used in the layers is the activation function ‘Relu’. There are also activation functions available from TensorFlow. Here is a link to all of them.

我们在图层中使用的另一个新参数是激活函数“ Relu”。 TensorFlow还提供了激活功能。 这里 是所有这些的链接。

Compile Model:

编译模型:

After we build the model we need to compile it. Here we need to select the loss functions and the optimizers. As you can see from the below code snippet this is very easy in TensorFlow. This is the same as we had in the last post.

构建模型后,我们需要对其进行编译。 在这里,我们需要选择损失函数和优化器。 从下面的代码片段中可以看出,在TensorFlow中这非常容易。 这与上一篇文章中的相同。

model.compile(     optimizer='Adam',     loss='sparse_categorical_crossentropy',     metrics=['accuracy'])

Fit Model:Without further ado, here is the simple fit line used to train the model.

拟合模型:事不宜迟,这是用于训练模型的简单拟合线。

model.fit(train_rescale,train_label,epochs=5)

Evaluate Model:Now the final test to see how the model performs on our test dataset.

评估模型:现在是最终测试,以查看模型在测试数据集上的表现。

model.evaluate(test_rescale,test_label)

Here is a quick reminder of how the Dense only model performed.

这是有关仅密集模型的执行情况的快速提醒。

part1第一部分

As you can see adding the 2 more lines in the model with Conv2D and MaxPooling2D improves the overall performance on the classification task from 87.72% to 91.12%.

如您所见,在使用Conv2D和MaxPooling2D的模型中添加另外2行,可以将分类任务的整体性能从87.72%提高到91.12%。

Good luck !!!

祝好运 !!!

翻译自: https://medium.com/@sailaja.karra/deep-learning-using-tensorflow-part2-aa956b24d84d


http://www.taodudu.cc/news/show-863791.html

相关文章:

  • 基于bert的语义匹配_构建基于BERT的语义搜索系统…针对“星际迷航”
  • 一个数据包的旅程_如何学习数据科学并开始您的惊人旅程
  • jupyter 托管_如何在本地托管的Jupyter Notebook上进行协作
  • fitbit手表中文说明书_如何获取和分析Fitbit睡眠分数
  • 熔池 沉积_用于3D打印的AI(第2部分):异常熔池检测的一课学习
  • 机器学习 可视化_机器学习-可视化
  • 学习javascript_使用5行JavaScript进行机器学习
  • 强化学习-动态规划_强化学习-第4部分
  • 神经网络优化器的选择_神经网络:优化器选择的重要性
  • 客户细分_客户细分:K-Means聚类和A / B测试
  • 菜品三级分类_分类器的惊人替代品
  • 开关变压器绕制教程_教程:如何将变压器权重和令牌化器从AllenNLP上传到HuggingFace
  • 一般线性模型和混合线性模型_线性混合模型如何工作
  • 为什么基于数字的技术公司进行机器人研究
  • 人类视觉系统_对人类视觉系统的对抗攻击
  • 在神经网络中使用辍学:不是一个神奇的子弹
  • 线程监视器模型_为什么模型验证如此重要,它与模型监视有何不同
  • dash使用_使用Dash和SHAP构建和部署可解释的AI仪表盘
  • 面向表开发 面向服务开发_面向繁忙开发人员的计算机视觉
  • 可视化 nltk_词嵌入:具有Genism,NLTK和t-SNE可视化的Word2Vec
  • fitbit手表中文说明书_使用机器学习预测Fitbit睡眠分数
  • redis生产环境持久化_在SageMaker上安装持久性Julia环境
  • alexnet vgg_从零开始:建立著名的分类网2(AlexNet / VGG)
  • 垃圾邮件分类 python_在python中创建SMS垃圾邮件分类器
  • 脑电波之父:汉斯·贝格尔_深度学习,认识聪明的汉斯
  • PyCaret 2.0在这里-新增功能?
  • 特征选择 回归_如何执行回归问题的特征选择
  • 建立神经网络来预测贷款风险
  • redshift教程_分析和可视化Amazon Redshift数据—教程
  • 白雪小町_町

使用TensorFlow进行深度学习-第2部分相关推荐

  1. DL框架之TensorFlow:深度学习框架TensorFlow Core(低级别TensorFlow API)的简介、安装、使用方法之详细攻略

    DL框架之TensorFlow:TensorFlow Core(低级别TensorFlow API)的简介.安装.使用方法之详细DL框架之TensorFlow:深度学习框架TensorFlow Cor ...

  2. TensorFlow:深度学习框架TensorFlow TensorFlow_GPU的简介、安装、测试之详细攻略

    TensorFlow:深度学习框架TensorFlow & TensorFlow_GPU的简介.安装.测试之详细攻略 目录 TensorFlow的简介 TensorFlow的安装 1.tens ...

  3. DL框架之Tensorflow:深度学习框架Tensorflow的简介、安装、使用方法之详细攻略

    DL框架之Tensorflow:深度学习框架Tensorflow的简介.安装.使用方法之详细攻略 目录 Tensorflow的简介 1.描述 2.TensorFlow的六大特征 3.了解Tensorf ...

  4. TensorFlow (RNN)深度学习 双向LSTM(BiLSTM)+CRF 实现 sequence labeling 序列标注问题 源码下载...

    http://blog.csdn.net/scotfield_msn/article/details/60339415 在TensorFlow (RNN)深度学习下 双向LSTM(BiLSTM)+CR ...

  5. 报名 | NVIDIA线下交流会:手把手教你搭建TensorFlow Caffe深度学习服务器

    7月21日(周六)下午14:30,量子位与NVIDIA英伟达开发者社区联合举办线下交流会,拥有丰富一线开发经验的NVIDIA开发者社区经理Ken He,将手把手教你搭建TensorFlow & ...

  6. Windows+Anaconda+tensorflow+keras深度学习框架搭建--reproduced

    转载于网络,已备查用. 现在把windows下的Anaconda+tensorflow+keras深度学习框架搭建过程记录如下 1.下载安装Anaconda记住支持版本一定是python3以上的版本 ...

  7. TensorFlow及深度学习相关资料积累汇总【不定期更新】

    此为学习TensorFlow及深度学习方面时收集到的一些资料,不定期汇总到这里,与大家一起学习.交流.讨论. 1.文档.书籍 TF官方文档中文版 首本中文教程:TensorFlow实战(京东) TF入 ...

  8. 斯坦福大学Tensorflow与深度学习实战课程

    分享一套Stanford University 在2017年1月份推出的一门Tensorflow与深度学习实战的一门课程.该课程讲解了最新版本的Tensorflow中各种概念.操作和使用方法,并且给出 ...

  9. 《纯干货-6》Stanford University 2017年最新《Tensorflow与深度学习实战》视频课程分享

    分享一套Stanford University 在2017年1月份推出的一门Tensorflow与深度学习实战的一门课程.该课程讲解了最新版本的Tensorflow中各种概念.操作和使用方法,并且给出 ...

  10. 使用RTX3080显卡搭建基于Pycharm+Python+Cuda+cuDNN+TensorFlow的深度学习开发环境

    本文链接:https://blog.csdn.net/tjhyx2012/article/details/112955582 作为一名新手,也是出于兴趣,我通过查找有关资料,使用RTX3080显卡搭建 ...

最新文章

  1. 光伏电价断崖式下跌 企业遭遇成长烦恼
  2. ubuntu linux下解决“no java virtual machine was found after searching the following locations:”的方法
  3. Android 显示、隐藏状态栏和导航栏
  4. 数学编程:经典数学编程案例之斐波那契:斐波那契数列的简介、代码实现、exe程序应用(斐波纳契时钟设计)之详细攻略
  5. 华为宣布了,手机将全面支持鸿蒙!
  6. linux 两个驱动 竞争,Linux设备驱动第五章(并发和竞争)读书笔记(国外英文资料).doc...
  7. TensorFlow——实现线性回归算法
  8. Windows操作系统,启动Tomcat之后DOS窗口乱码处理
  9. armstrong number in python_Python3 From Zero——{最初的意识:008~初级实例演练}
  10. 如何实现扫码下载app
  11. 省钱兄(微信小程序、h5版本)uniapp淘宝客小程序源码商城前端源码
  12. 基于javaweb实现人脸识别
  13. 修改Foxmail日历,让星期一为每周第一天
  14. 一文回顾腾讯数字生态大会·微搭低代码专场
  15. VMware虚拟机安装使用及系统安装教程
  16. 计算机科学与技术需要什么要求,计算机科学与技术专业需要掌握哪些技能?
  17. 9.16日常学习笔记
  18. 每日三省吾身- 持续改进-持续集成
  19. 中国成为论文发表数量第一的国家
  20. 用 Javascript 编写λ演算解释器

热门文章

  1. Buffered缓存流
  2. 大数据学习路线copy自淘宝
  3. 备份到云端,准备好了吗?
  4. ITM_win_agentCPU内存占用较高
  5. 依附B2B平台照样做搜索营销
  6. LSI系新军搅局,PCIe固态盘混战?
  7. 这年头,胡萝卜也靠不住了
  8. 用asp.net画饼图
  9. 首席Execution官
  10. 关于JAP FetchType.LAZY(hibernate实现)的理解