A simple network to classify handwritten digits 分类手写数字的简单网络

Having defined neural networks, let’s return to handwriting recognition. We can split the problem of recognizing handwritten digits into two sub-problems. First, we’d like a way of breaking an image containing many digits into a sequence of separate images, each containing a single digit. For example, we’d like to break the image 
定义了神经网络,我们回到笔迹识别。我们可以将识别手写数字的问题切分为两个子问题。首先,我们需要找到一个方法将有许多数字的图片切分为一系列只有一个数字的图片。例如,我们要将下面的图片

into six separate images, 
切分为6张图片

We humans solve this segmentation problem with ease, but it’s challenging for a computer program to correctly break up the image. Once the image has been segmented, the program then needs to classify each individual digit. So, for instance, we’d like our program to recognize that the first digit above, 
人来解决这个切分问题是非常简单的,但是对于计算机程序来说要正确切分图片是十分具有挑战性的。一旦图片被切分后,程序需要将每个数字正确分类。因此,举例来说,我们需要我们的程序识别上面的第一个数字,

is a 5. 
是5.

We’ll focus on writing a program to solve the second problem, that is, classifying individual digits. We do this because it turns out that the segmentation problem is not so difficult to solve, once you have a good way of classifying individual digits. There are many approaches to solving the segmentation problem. One approach is to trial many different ways of segmenting the image, using the individual digit classifier to score each trial segmentation. A trial segmentation gets a high score if the individual digit classifier is confident of its classification in all segments, and a low score if the classifier is having a lot of trouble in one or more segments. The idea is that if the classifier is having trouble somewhere, then it’s probably having trouble because the segmentation has been chosen incorrectly. This idea and other variations can be used to solve the segmentation problem quite well. So instead of worrying about segmentation we’ll concentrate on developing a neural network which can solve the more interesting and difficult problem, namely, recognizing individual handwritten digits. 
我们将聚焦于编写程序来解决第二个问题,也就是识别单独数字的问题。我们这么做是因为一旦你找到很好的方法来识别单独数字,切分问题解决起来不是那么困难。这里有许多方法来解决切分问题。一个途径是尝试多种切分方法,然后用单个数字分类器来给每个切分方法的结果打分。如果分类器对切分的每个数字都能很好识别,那么这个切分将得到高分,反之如果分类器不能很好识别切分后的数字,那么这个切分将得到低分。这个思路是如果分类器在哪里出了问题,那么也许就是那里切分出来问题。这个方法和其他的变形可以解决切分问题解决的很好。所以与其担心切分,我们还不如集中解决开发一个可以解决更有趣更困难的问题,识别单个手写数字,的神经网络。

To recognize individual digits we will use a three-layer neural network: 
为了识别单个手写数字,我们将使用3层神经网络:

The input layer of the network contains neurons encoding the values of the input pixels. As discussed in the next section, our training data for the network will consist of many 28 by 28 pixel images of scanned handwritten digits, and so the input layer contains 784=28×28 neurons. For simplicity I’ve omitted most of the 784 input neurons in the diagram above. The input pixels are greyscale, with a value of 0.0 representing white, a value of 1.0 representing black, and in between values representing gradually darkening shades of grey. 
网络输入层的神经元对输入像素值进行编码。正如我们下一节将讨论的,我们的训练数据由许多28 乘28 像素的手写数字扫描图片组成,因此输入层包含784=28×28 个神经元。简化起见我在上图中省略了784 个输入神经元中的大部分。输入像素是灰阶的,0.0表示白色,1.0表示黑色,之间的值表示灰度。

The second layer of the network is a hidden layer. We denote the number of neurons in this hidden layer by n, and we’ll experiment with different values for n. The example shown illustrates a small hidden layer, containing just n=15 neurons. 
网络的第二层是隐含层。我们将隐含层的神经元个数记作n,我们将尝试不同的n。这个例子使用了小规模的隐含层,包含了n=15个神经元。

The output layer of the network contains 10 neurons. If the first neuron fires, i.e., has an output ≈1, then that will indicate that the network thinks the digit is a 0. If the second neuron fires then that will indicate that the network thinks the digit is a 1. And so on. A little more precisely, we number the output neurons from 0through 9, and figure out which neuron has the highest activation value. If that neuron is, say, neuron number 6, then our network will guess that the input digit was a 6. And so on for the other output neurons. 
网络的输出层包含10个神经元。如果第一个神经元被激活,也就是输出≈1,这表示网络认为这个数字是0。如果第二个神经元激活表示网络认为这个数字是1,等等。更准确的说,我们量化0到9的输出神经元,然后看看哪个神经元有最高的激活值。假设6的神经元最高,我们的网络将猜测输入数字是6。其他的神经元以此类推。

You might wonder why we use 10 output neurons. After all, the goal of the network is to tell us which digit (0,1,2,…,9) corresponds to the input image. A seemingly natural way of doing that is to use just 4 output neurons, treating each neuron as taking on a binary value, depending on whether the neuron’s output is closer to 0 or to 1. Four neurons are enough to encode the answer, since 24=16 is more than the 10 possible values for the input digit. Why should our network use 10 neurons instead? Isn’t that inefficient? The ultimate justification is empirical: we can try out both network designs, and it turns out that, for this particular problem, the network with 10 output neurons learns to recognize digits better than the network with 4 output neurons. But that leaves us wondering why using 10 output neurons works better. Is there some heuristic that would tell us in advance that we should use the 10-output encoding instead of the 4-output encoding? 
你也许会奇怪我们为什么用10个输出神经元。毕竟这个网络的目标是告诉我们哪个数字(0,1,2,…,9)对应于输入的图片。还有种很自然的想法是使用4个输出神经元,每个神经元看看输出更靠近与0或1选取一个二进制值。四个神经元足够对结果进行编码了,因为24=16超过了输入数字的10个可能结果。为什么我们反而要用10个神经元呢?这样做不是效率更低吗?最终的理由是经验主义的:我们可以尝试设计这两种网络,对于这个特定的问题,10个输出神经元的网络识别数字的效果比4个输出神经元的网络好。不过这使得我们好奇为什么使用10个输出神经元会得到更好的效果。有什么经验预先告诉我们应该使用10来对输出编码而不是4?

To understand why we do this, it helps to think about what the neural network is doing from first principles. Consider first the case where we use 10 output neurons. Let’s concentrate on the first output neuron, the one that’s trying to decide whether or not the digit is a 0. It does this by weighing up evidence from the hidden layer of neurons. What are those hidden neurons doing? Well, just suppose for the sake of argument that the first neuron in the hidden layer detects whether or not an image like the following is present: 
从基本原理上了解神经网络做了些什么可以帮助理解为什么我们这么做。考虑第一种情况我们使用10个输出神经元。让我们着重注意第一个输出神经元,它就是尝试判决数字是否是0。它将隐含层的神经元的输出加权求和。隐含层的神经元做了什么?设想隐含层的第一个神经元是来发现一个图片是否和下面的图案相似:

It can do this by heavily weighting input pixels which overlap with the image, and only lightly weighting the other inputs. In a similar way, let’s suppose for the sake of argument that the second, third, and fourth neurons in the hidden layer detect whether or not the following images are present: 
它可以通过提高那些和这个图片重叠的输入像素的权重,降低其他输入的权重来做到这个。以此类推,让我们设想第二,第三和第四个隐含层的神经元是来发现一个图片是否和下面的图案相似:

As you may have guessed, these four images together make up the 0 image that we saw in the line of digits shown earlier: 
也许你已经猜到了,这四个图像组合成立数字0的图像,正如我们之前看到的:

So if all four of these hidden neurons are firing then we can conclude that the digit is a 0. Of course, that’s not the only sort of evidence we can use to conclude that the image was a 0 - we could legitimately get a 0 in many other ways (say, through translations of the above images, or slight distortions). But it seems safe to say that at least in this case we’d conclude that the input was a 0. 
因此如果所有这四个隐含层神经元被激活,那么我们可以得出这个数字是0。当然,这不是仅有的证据我们能用来判决图片是0。我们可以通过多种其他的方法合理的推断它是0(也就是说,通过对上面的图片变换,或者轻微的变形)。但是可以说最少在这个例子中我们可以判决输入是0。

Supposing the neural network functions in this way, we can give a plausible explanation for why it’s better to have 10 outputs from the network, rather than 4. If we had 4 outputs, then the first output neuron would be trying to decide what the most significant bit of the digit was. And there’s no easy way to relate that most significant bit to simple shapes like those shown above. It’s hard to imagine that there’s any good historical reason the component shapes of the digit will be closely related to (say) the most significant bit in the output. 
这样设想神经网络函数,我们可以给出一个似乎合理的理由来解释为什么10输出的网络比4输出的网络要好。如果我们有4个输出,那么第一个输出神经元将尝试判决这个数字最显著的比特是什么。将最显著的比特和上面简单的形状联系起来可不是件容易的事。很难想象有其他好的经验理由来帮助我们将最显著的比特和数字各局部的形状联系在一起。

Now, with all that said, this is all just a heuristic. Nothing says that the three-layer neural network has to operate in the way I described, with the hidden neurons detecting simple component shapes. Maybe a clever learning algorithm will find some assignment of weights that lets us use only 4 output neurons. But as a heuristic the way of thinking I’ve described works pretty well, and can save you a lot of time in designing good neural network architectures. 
现在,综上所述,这都是经验型的。没有什么证明3层神经网络是按照我描述的隐含层神经元检测局部简单形状这样工作的。也许有更聪明的算法可以找到权重分配来让我们仅仅使用4个输出神经元。但是按照我描述的作为经验方法去想还是可以较好理解的,并且可以帮你在设计神经网络结构的时候节省不少时间。

Exercise

There is a way of determining the bitwise representation of a digit by adding an extra layer to the three-layer network above. The extra layer converts the output from the previous layer into a binary representation, as illustrated in the figure below. Find a set of weights and biases for the new output layer. Assume that the first 3layers of neurons are such that the correct output in the third layer (i.e., the old output layer) has activation at least 0.99, and incorrect outputs have activation less than 0.01. 
通过在三层网络上增加额外的一层可以识别数字的二进制表示。这额外的一层将前面一层的输出转换为二进制表示,如下图所示。为新的输出层找到一组权重和偏置。假设前三层神经元输出的不是大于0.99就是小于0.01。

转自:http://blog.csdn.net/forrestyanyu/article/details/54861019

神经网络与深度学习(第一章)(五)相关推荐

  1. 神经网络与深度学习笔记汇总五

    神经网络与深度学习笔记汇总五 往期回顾 将之前掘金写的学习笔记所遇困难搬到这里,方便查看复习 遇到问题: 报错 (未解决) 学习内容: 1.报错operand should contain 1 col ...

  2. 神经网络与深度学习笔记 (五)深层神经网络

    摘要:本文知识点主要有简单介绍深层神经网络.深层神经网络的传播过程.保证矩阵维数的正确性.深度神经网络强大的原因.神经网络正向传播和反向传播的流程图.参数和超参数和神经网络与人脑机制的关系. 1.深层 ...

  3. 零基础入门深度学习 | 第一章:感知器

    北京 | 高性能计算之GPU CUDA课程11月24-26日3天密集学习 快速带你晋级阅读全文> 无论即将到来的是大数据时代还是人工智能时代,亦或是传统行业使用人工智能在云上处理大数据的时代,作 ...

  4. 吴恩达 神经网络和深度学习 第一课 第四周(代码和库)

    参考博客(主代码):https://blog.csdn.net/u013733326/article/details/79767169 下面是需要的库文件代码:testCases,dnn_utils_ ...

  5. 吴恩达 神经网络和深度学习 第一课 第三周 (代码)planar data classify

    (主要是记录自己的学习轨迹,顺便可以为需要的提供一些需要,仅供参考) 主要实现代码和使用.py文件: 1)主要代码部分实现流程: 1.获取数据 2.初始化参数(w1,b1,w2,b2返回参数) 3.向 ...

  6. 吴恩达 神经网络和深度学习 第一课 第一周(笔记,代码,数据集)

    推荐博客: https://blog.csdn.net/qq_25436597/article/details/78847831(这个博客上面是coursera的题目) https://blog.cs ...

  7. 深度学习第一章(rnn)

    cnn与rnn区别: cnn需要固定长度的输入.输出,rnn的输入和输出可以是不定长.不等长的 cnn只有one to one ,rnn有onetoone,onetomany(图像生成文字),many ...

  8. 神经网络与深度学习(邱锡鹏)-学习笔记

    神经网络与深度学习 第一章 绪论 第二章 机器学习概述 第三章 线性模型 深度学习是机器学习的一个分支,是指一类问题以及解决这类问题的方法.人工神经网络,也简称神经网络,是一种受人脑神经系统的工作方式 ...

  9. 神经网络与深度学习复习大纲

    第一章(问答题) 1.神经网络是什么?深度学习是什么? 神经网络:一种以(人工))神经元为基本单元的模型 深度学习:一类机器学习问题,主要解决贡献度分配问题 2.常用的深度学习框架是什么? Paddl ...

  10. 神经网络与深度学习笔记汇总二

    神经网络与深度学习笔记汇总二 正交化(方便调整参数) 迭代 单实数评估指标(判断几种手段/方法哪个更好) 指标选取 训练集.开发集.测试集作用与用途 评估指标 判断算法是好是坏 迁移学习 总结 往期回 ...

最新文章

  1. 只需25美元,算力提升3倍:树莓派4计算模组上线
  2. python3网络编程中semaphore用法_python3 进程信号量semaphore
  3. Centos7如何开启端口
  4. php 变量的8类类型
  5. 小鹏汽车高管个人年薪超4亿?网友:超过我对金钱的认知了
  6. python如何爬虫eps数据_Python爬虫常用的几种数据保存方式
  7. log4j.dtd_Eclipse log4j.xml –无法将log4j.dtd验证为XML定义
  8. Linux环境安装Redis高可用及配置主从复制、哨兵模式、分布式集群模式
  9. Excel数据透视表制作
  10. 数据库实验1---创建数据库和表
  11. 斐波那契数列 一般而言,兔子在出生两个月后,就有繁殖能力,一对兔子每个月能生出一对小兔子来。如果所有兔子都不死,那么一年以后可以繁殖多少对兔子?
  12. 7篇ICLR论文,遍览联邦学习最新研究进展
  13. Python高速缓存和会话库——Beaker
  14. JAVA作业三:教练与运动员案例
  15. elasticjob已下线_elasticJob 源码解析之自诊断恢复
  16. Apple Watch Ultra和Apple Watch Series 8 区别 续航 功能介绍
  17. HTML5+CSS期末大作业:运动体育网站设计主题——体育铅球(5页)带注册 期末作业HTML代码 学生网页课程设计期末作业下载 web网页设计制作成品...
  18. 【工具】PrimoCache和Qiling:快速缓存优化加速软件
  19. 计算机核心刊物投稿心得
  20. javaScript盲点梳理 -- 大白话

热门文章

  1. 离职时,是在公司群里大方告别,主动退群?还是一言不发,默默退出?
  2. java aes iv_java AES加密解密
  3. 第四百九十五日:念念不忘,必有回响
  4. WARNING: disk usage in log directory [/home/.../.ros/log] is over 1GB. 问题解决办法
  5. 微信测试之本地接口测试-ngrok
  6. 无聊科技正经事周刊(第3期):美团的推荐算法,是在玩火吗?
  7. Kubernetes 之 集群二进制部署
  8. 用matlab解超越方程,MATLAB实例之对线性,非线性,超越方程的求解
  9. 数据库--聚集函数及其应用
  10. SMILES Enumeration