神经网络:表达(三)

示例一
神经网络:表达(三)_第1张图片

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

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

神经网络:表达(三)_第2张图片

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

神经网络:表达(三)_第3张图片

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

神经网络:表达(三)_第4张图片

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

神经网络:表达(三)_第5张图片

由上图可知,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:

神经网络:表达(三)_第6张图片

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:

神经网络:表达(三)_第7张图片

Where g(z) is the following:

神经网络:表达(三)_第8张图片
示例二
神经网络:表达(三)_第9张图片

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

神经网络:表达(三)_第10张图片

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

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

神经网络:表达(三)_第11张图片

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

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

神经网络:表达(三)_第12张图片

其结果为:

神经网络:表达(三)_第13张图片
补充笔记
Examples and Intuitions II

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

神经网络:表达(三)_第14张图片

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

神经网络:表达(三)_第15张图片

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:

神经网络:表达(三)_第16张图片

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

神经网络:表达(三)_第17张图片
多类别分类问题

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

神经网络:表达(三)_第18张图片

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:

神经网络:表达(三)_第19张图片

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:

神经网络:表达(三)_第20张图片

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

神经网络:表达(三)_第21张图片

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

你可能感兴趣的:(神经网络:表达(三))