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.
![](https://i-blog.csdnimg.cn/blog_migrate/04c5dfc062af097362bdb0c5fb9f1aab.png)
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:
![](https://i-blog.csdnimg.cn/blog_migrate/7c7bb8b34564e5250ad99a684d8cc5b4.png)
Not that the meaning of the superscripts [] & (). For example, 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:
![](https://i-blog.csdnimg.cn/blog_migrate/1e716eda38da410a248d7e0665fe7f71.png)
Here we form by stacking all training example in columns. Similarly, for
, we just stack all
horizontally; for
, we stack all
. Note that for multiple m traing examples, we just use capital case
.
One interesting property is, for these matrices , 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.
![](https://i-blog.csdnimg.cn/blog_migrate/f5bb736372790509e255eaa76ca00cd8.png)
<end>