神经网络:表达(二)

模型表达Ⅰ(Model Representation Ⅰ)

为了构建神经网络模型,我们需要借鉴大脑中的神经系统。每一个神经元都可以作为一个处理单元(Processing Unit)或神经核(Nucleus),其拥有众多用于输入的树突(Dendrite)和用于输出的轴突(Axon),其中神经元通过传递电脉冲来传递信息。

神经网络模型由一个个“神经元”构成,而每一个“神经元”又为一个学习模型,我们将这些“神经元”称为激活单元(Activation Unit)。

其中,参数θ在神经网络中也被称为权重,假设函数hθ(x) = g(z),新增的x0称为偏置单元(Bias Unit)。

在神经网络模型中(以三层神经网络模型为例),第一层为输入层(Input Layer),最后一层为输出层(Output Layer),中间的这层称为隐藏层(Hidden Layer)。

我们引入如下标记用于描述神经网络模型:

  • ai(j):表示第j层的第i个激活单元;
  • θ(j):表示从第j层映射到第j+1层时权重矩阵。

注:在神经网络模型中,如若第j层有sj个激活单元,在第j+1层有sj+1个激活单元,则权重矩阵θ(j)的维度为sj+1 * (sj+1)。因此,上图中权重矩阵θ(1)的维度3*4。

对于上图所示的神经网络模型,我们可用如下数学表达式表示:

在逻辑回归中,我们被限制使用数据集中的原始特征变量x,虽然我们可以通过多项式来组合这些特征,但我们仍然受到原始特征变量x的限制。

在神经网络中,原始特征变量x只作为输入层,输出层所做出的预测结果利用的是隐藏层的特征变量,由此我们可以认为隐藏层中特征变量是通过神经网络模型学习后,将得到的新特征用于预测结果,而非使用原始特征变量x用于预测结果。

补充笔记
Model Representation I

Visually, a simplistic representation looks like:

Our input nodes (layer 1), also known as the "input layer", go into another node (layer 2), which finally outputs the hypothesis function, known as the "output layer".

We can have intermediate layers of nodes between the input and output layers called the "hidden layers."

In this example, we label these intermediate or "hidden" layer nodes a02⋯an2 and call them "activation units."

If we had one hidden layer, it would look like:

The values for each of the "activation" nodes is obtained as follows:

This is saying that we compute our activation nodes by using a 3×4 matrix of parameters. We apply each row of the parameters to our inputs to obtain the value for one activation node. Our hypothesis output is the logistic function applied to the sum of the values of our activation nodes, which have been multiplied by yet another parameter matrix Θ(2) containing the weights for our second layer of nodes.

Each layer gets its own matrix of weights, Θ(j).

The dimensions of these matrices of weights is determined as follows:

If network has sj units in layer j and sj+1 units in layer j+1, then Θ(j) will be of dimension sj+1×(sj+1).

The +1 comes from the addition in Θ(j) of the "bias nodes," x0 and Θ0(j). In other words the output nodes will not include the bias nodes while the inputs will. The following image summarizes our model representation:

模型表达Ⅱ(Model Representation II)

以此图为例,之前我们介绍其数学表达式。为了方便编码及运算,我们将其向量化。

其中:

因此,我们可将之前的数学表达式改写为:

其中向量X可记为a(1),则z(2) = Θ(1)a(1)。由此可得,a(2) = g(z(2))。

此时假设函数hθ(x)可改写为:

其中:

补充笔记
Model Representation II

To re-iterate, the following is an example of a neural network:

In this section we'll do a vectorized implementation of the above functions. We're going to define a new variable zk(j) that encompasses the parameters inside our g function. In our previous example if we replaced by the variable z for all the parameters we would get:

In other words, for layer j=2 and node k, the variable z will be:

The vector representation of x and zj is:

Setting x=a(1), we can rewrite the equation as:

We are multiplying our matrix Θ(j−1) with dimensions sj×(n+1) (where sj is the number of our activation nodes) by our vector a(j−1) with height (n+1). This gives us our vector z(j) with height sj. Now we can get a vector of our activation nodes for layer j as follows:

Where our function g can be applied element-wise to our vector z(j).

We can then add a bias unit (equal to 1) to layer j after we have computed a(j). This will be element a0(j) and will be equal to 1. To compute our final hypothesis, let's first compute another z vector:

We get this final z vector by multiplying the next theta matrix after Θ(j−1) with the values of all the activation nodes we just got. This last theta matrix Θ(j) will have only one row which is multiplied by one column a(j) so that our result is a single number. We then get our final result with:

Notice that in this last step, between layer j and layer j+1, we are doing exactly the same thing as we did in logistic regression. Adding all these intermediate layers in neural networks allows us to more elegantly produce interesting and more complex non-linear hypotheses.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,692评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,482评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,995评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,223评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,245评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,208评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,091评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,929评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,346评论 1 311
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,570评论 2 333
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,739评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,437评论 5 344
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,037评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,677评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,833评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,760评论 2 369
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,647评论 2 354

推荐阅读更多精彩内容

  • 可以去除鱼腥的有: 肉豆蔻、月桂、丁香、众香子、洋葱、肉桂、大蒜、葱姜、鼠尾草、小豆蔻、香菜等; 可以去除羊肉膻味...
    遇见最美的ni阅读 13,947评论 2 5
  • 今日你一身红装 盘起的秀发 精致的头饰 想必是极美的 心底也是甜蜜幸福的 婚礼的规程风俗想必也很繁琐劳累 但走过这...
    小明的小红的故事阅读 317评论 0 1
  • 公子有一把黑纸伞,是曾祖父那辈人传下来的,落满了时间的灰尘,伞面虽陈旧些伞骨却依然完好,不过总是挂在墙上,从未撑开...
    北风起兮阅读 337评论 0 0
  • 这个察觉是没有想到的结果,哈哈 先一步步来吧。 在家里,我和弟弟的形象几乎是反的,我做什么做得好,他肯...
    木棉水水阅读 629评论 0 49
  • 不想与你再有牵扯,我断了你的所有联系。 一切又重新浮现在我眼前。初夏的时节,风是和煦的,林荫道上投下上午温暖的树影...
    暮之心阅读 255评论 0 0