【中英】【吴恩达课后测验】Course 1 - 神经网络和深度学习 - 第三周测验


上一篇:【 课程1 - 第二周编程作业】
<https://blog.csdn.net/u013733326/article/details/79639509>※※※※※ 【回到目录】
<https://blog.csdn.net/u013733326/article/details/79827273>※※※※※下一篇:【课程1 -
第三周编程作业】 <https://blog.csdn.net/u013733326/article/details/79702148>



第3周测验 - 浅层神经网络

*
以下哪一项是正确的?

* 【★】X是一个矩阵,其中每个列都是一个训练示例。
* 【★】a[2]4a4[2] 是第二层第四层神经元的激活的输出。
* 【★】a[2](12)a[2](12)表示第二层和第十二层的激活向量。
* 【★】a[2]a[2] 表示第二层的激活向量。
注意:如果您不熟悉本课程所使用的符号,请 戳我
<https://www.coursera.org/learn/neural-networks-deep-learning/resources/YsZjP>。
博主注:我只列出了正确的答案。

*
tanh激活函数通常比隐藏层单元的sigmoid激活函数效果更好,因为其输出的平均值更接近于零,因此它将数据集中在下一层是更好的选择,请问正确吗?

* 【★】True
* 【 】 False
请注意,你可以看一下这篇文章 <https://stats.stackexchange.com/a/101563/169377> 和这篇文档
<http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf>.

As seen in lecture the output of the tanh is between -1 and 1, it thus centers
the data which makes the learning simpler for the next layer.

正如视频中所看到的,tanh的输出在-1和1之间,因此它将数据集中在一起,使得下一层的学习变得更加简单。

*
其中哪一个是第l层向前传播的正确向量化实现,其中1≤l≤L1≤l≤L

* Z[l]=W[l]A[l−1]+b[l]Z[l]=W[l]A[l−1]+b[l]
* A[l]=g[l](Z[l])A[l]=g[l](Z[l])
博主注:我只列出了正确的答案。

*
您正在构建一个识别黄瓜(y = 1)与西瓜(y = 0)的二元分类器。 你会推荐哪一种激活函数用于输出层?

* 【 】 ReLU
* 【 】 Leaky ReLU
* 【★】sigmoid
* 【 】 tanh
注意:来自sigmoid函数的输出值可以很容易地理解为概率。

Sigmoid outputs a value between 0 and 1 which makes it a very good choice for
binary classification. You can classify as 0 if the output is less than 0.5 and
classify as 1 if the output is more than 0.5. It can be done with tanh as well
but it is less convenient as the output is between -1 and 1.


Sigmoid输出的值介于0和1之间,这使其成为二元分类的一个非常好的选择。 如果输出小于0.5,则可以将其归类为0,如果输出大于0.5,则归类为1。
它也可以用tanh来完成,但是它不太方便,因为输出在-1和1之间。

*
看一下下面的代码:
A = np.random.randn(4,3) B = np.sum(A, axis = 1, keepdims = True)
请问B.shape的值是多少?

B.shape = (4, 1)

we use (keepdims = True) to make sure that A.shape is (4,1) and not (4, ). It
makes our code more rigorous.


我们使用(keepdims = True)来确保A.shape是(4,1)而不是(4,),它使我们的代码更加严格。

*
假设你已经建立了一个神经网络。 您决定将权重和偏差初始化为零。 以下哪项陈述是正确的?

* 【★】第一个隐藏层中的每个神经元节点将执行相同的计算。 所以即使经过多次梯度下降迭代后,层中的每个神经元节点都会计算出与其他神经元节点相同的东西。
* 【 】 第一个隐藏层中的每个神经元将在第一次迭代中执行相同的计算。 但经过一次梯度下降迭代后,他们将学会计算不同的东西,因为我们已经“破坏了对称性”。
* 【 】第一个隐藏层中的每一个神经元都会计算出相同的东西,但是不同层的神经元会计算不同的东西,因此我们已经完成了“对称破坏”。
* 【 】即使在第一次迭代中,第一个隐藏层的神经元也会执行不同的计算, 他们的参数将以自己的方式不断发展。
*
Logistic回归的权重w应该随机初始化,而不是全零,因为如果初始化为全零,那么逻辑回归将无法学习到有用的决策边界,因为它将无法“破坏对称性”,是正确的吗?

* 【 】True
* 【★】False
Logistic Regression doesn’t have a hidden layer. If you initialize the weights
to zeros, the first example x fed in the logistic regression will output zero
but the derivatives of the Logistic Regression depend on the input x (because
there’s no hidden layer) which is not zero. So at the second iteration, the
weights values follow x’s distribution and are different from each other if x
is not a constant vector.


Logistic回归没有隐藏层。
如果将权重初始化为零,则Logistic回归中的第一个示例x将输出零,但Logistic回归的导数取决于不是零的输入x(因为没有隐藏层)。
因此,在第二次迭代中,如果x不是常量向量,则权值遵循x的分布并且彼此不同。

*
您已经为所有隐藏单元使用tanh激活建立了一个网络。 使用np.random.randn(..,..)* 1000将权重初始化为相对较大的值。 会发生什么?

*
【 】这没关系。只要随机初始化权重,梯度下降不受权重大小的影响。

*
【 】这将导致tanh的输入也非常大,因此导致梯度也变大。因此,您必须将α设置得非常小以防止发散; 这会减慢学习速度。

*
【 】这会导致tanh的输入也非常大,导致单位被“高度激活”,从而加快了学习速度,而权重必须从小数值开始。

*
【★】这将导致tanh的输入也很大,因此导致梯度接近于零, 优化算法将因此变得缓慢。

tanh becomes flat for large values, this leads its gradient to be close to
zero. This slows down the optimization algorithm.


tanh对于较大的值变得平坦,这导致其梯度接近于零。 这减慢了优化算法。

*
看一下下面的单隐层神经网络:


* 【★】b[1]b[1] 的维度是(4, 1)
* 【★】W[1]W[1] 的维度是 (4, 2)
* 【★】W[2]W[2] 的维度是 (1, 4)
* 【★】b[2]b[2] 的维度是 (1, 1)
博主注:我只列出了正确的答案。

请注意: 点击这里
<https://user-images.githubusercontent.com/14886380/29200515-7fdd1548-7e88-11e7-9d05-0878fe96bcfa.png>
来看一下公式。

*
I在和上一个相同的网络中,z[1]z[1] 和 A[1]A[1]的维度是多少?

* 【★】z[1]z[1] 和 A[1]A[1] 的维度都是 (4,m)
博主注:我只列出了正确的答案。

请注意: 点击这里
<https://user-images.githubusercontent.com/14886380/29200515-7fdd1548-7e88-11e7-9d05-0878fe96bcfa.png>
来看一下公式。

Week 3 Quiz - Shallow Neural Networks

*
Which of the following are true? (Check all that apply.) Notice that I only
list correct options.

* X is a matrix in which each column is one training example.
* a^[2]_4 is the activation output by the 4th neuron of the 2nd layer
* a^[2](12) denotes the activation vector of the 2nd layer for the 12th
training example.
* a^[2] denotes the activation vector of the 2nd layer.
Note: If you are not familiar with the notation used in this course, check here
<https://www.coursera.org/learn/neural-networks-deep-learning/resources/YsZjP>.

*
The tanh activation usually works better than sigmoid activation function for
hidden units because the mean of its output is closer to zero, and so it
centers the data better for the next layer. True/False?

* [x] True
* [ ] False
Note: You can check this post <https://stats.stackexchange.com/a/101563/169377>
and (this paper)[http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf]
<http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf]>.

As seen in lecture the output of the tanh is between -1 and 1, it thus centers
the data which makes the learning simpler for the next layer.

*
Which of these is a correct vectorized implementation of forward propagation
for layer l, where 1鈮鈮?

* Z^[l]=W^[l]A^[l−1]+b^[l]
* A^[l]=g^[l](Z^[l])
*
You are building a binary classifier for recognizing cucumbers (y=1) vs.
watermelons (y=0). Which one of these activation functions would you recommend
using for the output layer?

* [ ] ReLU
* [ ] Leaky ReLU
* [x] sigmoid
* [ ] tanh
Note: The output value from a sigmoid function can be easily understood as a
probability.

Sigmoid outputs a value between 0 and 1 which makes it a very good choice for
binary classification. You can classify as 0 if the output is less than 0.5 and
classify as 1 if the output is more than 0.5. It can be done with tanh as well
but it is less convenient as the output is between -1 and 1.

*
Consider the following code:
A = np.random.randn(4,3) B = np.sum(A, axis = 1, keepdims = True)
What will be B.shape?

B.shape = (4, 1)

we use (keepdims = True) to make sure that A.shape is (4,1) and not (4, ). It
makes our code more rigorous.

*
Suppose you have built a neural network. You decide to initialize the weights
and biases to be zero. Which of the following statements are True? (Check all
that apply)

* Each neuron in the first hidden layer will perform the same computation. So
even after multiple iterations of gradient descent each neuron in the layer
will be computing the same thing as other neurons.
* Each neuron in the first hidden layer will perform the same computation in
the first iteration. But after one iteration of gradient descent they will
learn to compute different things because we have “broken symmetry”.
* Each neuron in the first hidden layer will compute the same thing, but
neurons in different layers will compute different things, thus we have
accomplished “symmetry breaking” as described in lecture.
* The first hidden layer’s neurons will perform different computations from
each other even in the first iteration; their parameters will thus keep
evolving in their own way.
*
Logistic regression’s weights w should be initialized randomly rather than to
all zeros, because if you initialize to all zeros, then logistic regression
will fail to learn a useful decision boundary because it will fail to “break
symmetry”, True/False?

* [ ] True
* [x] False
Logistic Regression doesn’t have a hidden layer. If you initialize the weights
to zeros, the first example x fed in the logistic regression will output zero
but the derivatives of the Logistic Regression depend on the input x (because
there’s no hidden layer) which is not zero. So at the second iteration, the
weights values follow x’s distribution and are different from each other if x
is not a constant vector.

*
You have built a network using the tanh activation for all the hidden units.
You initialize the weights to relative large values, using
np.random.randn(..,..)*1000. What will happen?

*
[ ] It doesn’t matter. So long as you initialize the weights randomly gradient
descent is not affected by whether the weights are large or small.

*
[ ] This will cause the inputs of the tanh to also be very large, thus causing
gradients to also become large. You therefore have to set 伪 to be very small to
prevent divergence; this will slow down learning.

*
[ ] This will cause the inputs of the tanh to also be very large, causing the
units to be “highly activated” and thus speed up learning compared to if the
weights had to start from small values.

*
[x] This will cause the inputs of the tanh to also be very large, thus causing
gradients to be close to zero. The optimization algorithm will thus become slow.

tanh becomes flat for large values, this leads its gradient to be close to
zero. This slows down the optimization algorithm.

*
Consider the following 1 hidden layer neural network:

* b[1] will have shape (4, 1)
* W[1] will have shape (4, 2)
* W[2] will have shape (1, 4)
* b[2] will have shape (1, 1)
Note: Check here
<https://user-images.githubusercontent.com/14886380/29200515-7fdd1548-7e88-11e7-9d05-0878fe96bcfa.png>
for general formulas to do this.

*
In the same network as the previous question, what are the dimensions of Z^[1]
and A^[1]?

* Z[1] and A[1] are (4,m)
Note: Check here
<https://user-images.githubusercontent.com/14886380/29200515-7fdd1548-7e88-11e7-9d05-0878fe96bcfa.png>
for general formulas to do this.

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信