神经网络:表达(三)

示例一

如上图所示,假设函数hΘ(x)可用数学表达式表示为:

其中,g(z)函数图像如图所示:

因此,令x1和x2分别为0和1,可得如下表达式:

从上图中,我们可以发现x1和x2呈现出逻辑关系中的与(AND)。

同理,我们可得如下结果:

由上图可知,x1和x2呈现出逻辑关系中的或(OR)。

补充笔记
Examples and Intuitions I

A simple example of applying neural networks is by predicting x1 AND x2, which is the logical 'and' operator and is only true if both x1 and x2 are 1.

The graph of our functions will look like:

Remember that x0 is our bias variable and is always 1.

Let's set our first theta matrix as:

This will cause the output of our hypothesis to only be positive if both x1 and x2 are 1. In other words:

So we have constructed one of the fundamental operations in computers by using a small neural network rather than using an actual AND gate. Neural networks can also be used to simulate all the other logical gates. The following is an example of the logical operator 'OR', meaning either x1 is true or x2 is true, or both:

Where g(z) is the following:

示例二

与之前同理,我们可得如下结果:

由上图可知,x1呈现出逻辑关系中的非(NOT)。

我们综上所述可推得,当且仅当x1 = x2 = 0时,(NOT x1) AND (NOT x2)为1。

利用上图中三种逻辑关系,构建异或非逻辑关系的神经网络模型。

其神经网络模型如下图所示:

其结果为:

补充笔记
Examples and Intuitions II

The Θ(1) matrices for AND, NOR, and OR are:

We can combine these to get the XNOR logical operator (which gives 1 if x1 and x2 are both 0 or both 1).

For the transition between the first and second layer, we'll use a Θ(1) matrix that combines the values for AND and NOR:

For the transition between the second and third layer, we'll use a Θ(2) matrix that uses the value for OR:

Let's write out the values for all our nodes:

And there we have the XNOR operator using a hidden layer with two nodes! The following summarizes the above algorithm:

多类别分类问题

若我们要构建一个神经网络模型来识别图中的路人、汽车、摩托车和卡车,那么其模型在输出层应该有4个激活单元,其中我们用0和1分别表示不是和是。

Question:
Suppose you have a multi-class classification problem with 10 classes. Your neural network has 3 layer, and the hidden layer (layer 2) has 5 units. Using the one-vs-all method described here, how many elements does Θ(2) have?
A. 50
B. 55
C. 60
D. 65

根据神经网络:表达(二)一文中的数学公式,以及多类别分类问题的特性,我们不难选出C这个正确答案。

补充笔记
Multiclass Classification

To classify data into multiple classes, we let our hypothesis function return a vector of values. Say we wanted to classify our data into one of four categories. We will use the following example to see how this classification is done. This algorithm takes as input an image and classifies it accordingly:

We can define our set of resulting classes as y:

Each y(i) represents a different image corresponding to either a car, pedestrian, truck, or motorcycle. The inner layers, each provide us with some new information which leads to our final hypothesis function. The setup looks like:

Our resulting hypothesis for one set of inputs may look like:

In which case our resulting class is the third one down, or hΘ(x)3, which represents the motorcycle.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 拳头,也是一种语言。 专业伦理,专业素养,人不等于问题,人只会遇到问题,想办法去解决人遇到问题,而不是去解决人。每...
    土豆哦阅读 189评论 0 0
  • 参考书目:《气质》[美] 奥里森·斯威特·马登 气质这个词总是与“优雅”,“得体”等等美好的词语联系在一起。 不可...
    酒十三阅读 1,160评论 0 6
  • 这里将作为个人blog记录本人在各方面的点点滴滴!
    huangturen2007阅读 297评论 0 0

友情链接更多精彩内容