One hidden layer Neural Network - Vectorizing across multiple examples

这篇博客介绍了如何在Andrew Ng的Coursera课程《神经网络与深度学习》中,通过向量化计算处理多个训练样本时神经网络的隐藏层和输出层。内容包括从单个样本的计算到批量样本的向量化优化,强调了在矩阵操作中,水平方向索引跨训练样本,垂直方向索引神经网络的不同节点。
摘要由CSDN通过智能技术生成

The notes when study the Coursera class by Mr. Andrew Ng "Neural Networks & Deep Learning", section 3.4 "Vectorizing across multiple examples". It shows how to compute NN output via vectorization when there are multiple training example. Share it with you and hope it helps!

————————————————
In last class, we saw how to compute NN output given a single training example. In this class, you see how to vectorize across multiple training examples.

figure-1

Figure-1 shows how to compute NN hidden layer and output layer when there is just one training example. 

When there are m training examples, following figure-2 shows a for loop going over all training examples:

figure-2

Not that the meaning of the superscripts [] & (). For example, z^{[1](i)} means layer 1 for training example i.

Following figure-3 shows how to compute NN hidden layer and output layer by vectorizing above for loop when there are multiple m examples:

figure-3

 Here we form X by stacking all training example in columns. Similarly, for Z^{[1]}, we just stack all z^{[1](i)} horizontally; for A^{[1]}, we stack all a^{[1](i)}. Note that for multiple m traing examples, we just use capital case X,Z,A.

One interesting property is, for these matrices Z,A, horizontally we're going to index across training examples; and vertically, index across different nodes in the NN. For example in figure-4, the red point corresponds to the activation of the first hidden unit on the first training example; the green point corresponds to the second hidden unit of the first training example; the cyan point maps to the first hidden unit on the mth training example etc.

figure-4

<end>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值