概述
Week5_1Neural Networks Learning
- Week5_1Neural Networks Learning
-
- 第 1 题
- 第 2 题
- 第 3 题
- 第 4 题
- 第 5 题
-
第 1 题
You are training a three layer neural network and would like to use backpropagation to compute the gradient of the cost function.
In the backpropagation algorithm, one of the steps is to update
Δ(2)ij:=Δ(2)ij+δ(3)i∗(a(2))j
Δ
i
j
(
2
)
:=
Δ
i
j
(
2
)
+
δ
i
(
3
)
∗
(
a
(
2
)
)
j
for every i,j. Which of the following is a correct vectorization of this step?
- Δ(2):=Δ(2)+(a(2))T∗δ(3) Δ ( 2 ) := Δ ( 2 ) + ( a ( 2 ) ) T ∗ δ ( 3 )
- Δ(2):=Δ(2)+(a(3))T∗δ(2) Δ ( 2 ) := Δ ( 2 ) + ( a ( 3 ) ) T ∗ δ ( 2 )
- Δ(2):=Δ(2)+δ(3)∗(a(2))T Δ ( 2 ) := Δ ( 2 ) + δ ( 3 ) ∗ ( a ( 2 ) ) T
- Δ(2):=Δ(2)+δ(3)∗(a(3))T Δ ( 2 ) := Δ ( 2 ) + δ ( 3 ) ∗ ( a ( 3 ) ) T
* 答案: 3 *
* *
第 2 题
Suppose Theta1 T h e t a 1 is a 5x3 matrix, and Theta2 T h e t a 2 is a 4x6 matrix. You set thetaVec=[Theta1(:);Theta2(:)] t h e t a V e c = [ T h e t a 1 ( : ) ; T h e t a 2 ( : ) ] . Which of the following correctly recovers Theta2 T h e t a 2 ?
- reshape(thetaVec(16:39),4,6) r e s h a p e ( t h e t a V e c ( 16 : 39 ) , 4 , 6 )
- reshape(thetaVec(15:38),4,6) r e s h a p e ( t h e t a V e c ( 15 : 38 ) , 4 , 6 )
- reshape(thetaVec(16:24),4,6) r e s h a p e ( t h e t a V e c ( 16 : 24 ) , 4 , 6 )
- reshape(thetaVec(15:39),4,6) r e s h a p e ( t h e t a V e c ( 15 : 39 ) , 4 , 6 )
-
reshape(thetaVec(16:39),6,4)
r
e
s
h
a
p
e
(
t
h
e
t
a
V
e
c
(
16
:
39
)
,
6
,
4
)
* 答案: 1 *
octave:1> A=[1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15]
A=⎡⎣⎢161127123813491451015⎤⎦⎥ A = [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ]
octave:2> B=[16 17 18; 19 20 21]
B=[161917201821] B = [ 16 17 18 19 20 21 ]
octave:3> V=[A(:);B(:)]
octave:4> reshape(V(15:20),3, 2)
ans=⎡⎣⎢151619172018⎤⎦⎥ a n s = [ 15 17 16 20 19 18 ]
octave:5> reshape(V(16:21),3, 2)
ans=⎡⎣⎢161917201821⎤⎦⎥ a n s = [ 16 20 19 18 17 21 ]
octave:6> reshape(V(16:21),2, 3)
ans=[161917201821] a n s = [ 16 17 18 19 20 21 ]
* Theta2 T h e t a 2 是一个4x6的矩阵,则resharp最后的行列也是4x6 *
* thetaVec中 Theta2 T h e t a 2 的开始是 Theta1 T h e t a 1 的结束+1,即5x3+1=16 *
* thetaVec中 Theta2 T h e t a 2 的结束是整个thetaVec的结束=5x3+4x6=39 *
* 所以最终的结果是: reshape(thetaVec(16:39),4,6) r e s h a p e ( t h e t a V e c ( 16 : 39 ) , 4 , 6 ) *
* 9-4 Implementation Note_Unrolling Parameters *
第 3 题
Let J(θ)=2θ3+2 J ( θ ) = 2 θ 3 + 2 . Let θ=1, and ϵ=0.01 ϵ = 0.01 . Use the formula J(θ+ϵ)−J(θ−ϵ)2ϵ J ( θ + ϵ ) − J ( θ − ϵ ) 2 ϵ to numerically compute an approximation to the derivative at θ=1 θ = 1 . What value do you get? (When θ=1, the true/exact derivati ve is dJ(θ)dθ=6 d J ( θ ) d θ = 6 .)
- 8
- 6
- 5.9998
- 6.0002
* 答案: 4 *
*
J(θ+ϵ)−J(θ−ϵ)2ϵ=2∗(θ+ϵ)3+2−(2∗(θ−ϵ)3+2)2ϵ
J
(
θ
+
ϵ
)
−
J
(
θ
−
ϵ
)
2
ϵ
=
2
∗
(
θ
+
ϵ
)
3
+
2
−
(
2
∗
(
θ
−
ϵ
)
3
+
2
)
2
ϵ
*
* 将
ϵ=0.01
ϵ
=
0.01
,
θ=1
θ
=
1
代入上式,并化简一下可得出 *
*
(θ+ϵ)3−(θ−ϵ)3ϵ=(1+0.01)3−(1−0.01)30.01=6.0002
(
θ
+
ϵ
)
3
−
(
θ
−
ϵ
)
3
ϵ
=
(
1
+
0.01
)
3
−
(
1
−
0.01
)
3
0.01
=
6.0002
*
第 4 题
Which of the following statements are true? Check all that apply.
- Using a large value of λ λ cannot hurt the performance of your neural network; the only reason we do not set λ λ to be too large is to avoid numerical problems.
- Gradient checking is useful if we are using gradient descent as our optimization algorithm. However, it serves little purpose if we are using one of the advanced optimization methods (such as in fminunc).
- Using gradient checking can help verify if one’s implementation of backpropagation is bug-free.
- If our neural network overfits the training set, one reasonable step to take is to increase the regularization parameter λ λ .
* 答案: 3 4 *
* 选项1: 以前的quiz中遇到过,当选的
λ
λ
太大时,会成为一条直线,underfit. 不正确 **
* 选项2: Gradient checking是验检神经网络内部的计算结果对不对,不关心是用的哪个算法,高级算法如fminuc与原始的sigmoid梯度下降都可以用gradient checking来验检. 不正确 **
* 选项3: Gradient checking就是用来验检神经网络内部的计算结果对不对的. 正确 **
* 选项4: 回忆一下当时引入正规化项Regularization的目的是什么? 是为了解决overfitting的问题. 假设设置的
λ
λ
太小了就相当于没有加入正规化项,penalize不够,还是会overfit,则需要加大
λ
λ
; 再补充另一方面,如果把
λ
λ
设置的太大了,就会成为一条直线,导致出现underfit. neural network 与 lr 是一样的. 正确 **
第 5 题
Which of the following statements are true? Check all that apply.
Suppose that the parameter Θ(1) Θ ( 1 ) is a square matrix (meaning the number of rows equals the number of columns). If we replace Θ(1) Θ ( 1 ) with its transpose (Θ(1))T ( Θ ( 1 ) ) T , then we have not changed the function that the network is computing.
Suppose we have a correct implementation of backpropagation, and are training a neural network using gradient descent. Suppose we plot J(Θ) J ( Θ ) as a function of the number of iterations, and find that it is increasing rather than decreasing. One possible cause of this is that the learning rate α α is too large.
Suppose we are using gradient descent with learning rate α α . For logistic regression and linear regression,
J(Θ) J ( Θ ) was a convex optimization problem and thus we did not want to choose a learning rate α α that is too large.
For a neural network however, J(Θ) J ( Θ ) may not be convex, and thus choosing a very large value of α α can only speed up convergence.If we are training a neural network using gradient descent, one reasonable “debugging” step to make sure it is working is to plot J(Θ) J ( Θ ) as a function of the number of iterations, and make sure it is decreasing (or at least non-increasing) after each iteration.
* 答案: 2 4 *
* 选项1: 神经网络的计算(network computing).以第2层为例:
a(2)=g(z(2))=g(Θ(1)∗a(1))
a
(
2
)
=
g
(
z
(
2
)
)
=
g
(
Θ
(
1
)
∗
a
(
1
)
)
, 当
Θ(1)
Θ
(
1
)
转置为
(Θ(1))T
(
Θ
(
1
)
)
T
时,显然
g(Θ(1)∗a(1))≠g((Θ(1))T∗a(1))
g
(
Θ
(
1
)
∗
a
(
1
)
)
≠
g
(
(
Θ
(
1
)
)
T
∗
a
(
1
)
)
. 不正确 **
* 选项2: 当选的
α
α
太大时,gradient descent有可能越过最低点,导致CostFunction的值越来越大. 正确 **
* 选项3: 没有确定神经网络的
J(Θ)
J
(
Θ
)
是不是一定是凸的(等大神指导),但是就算不是凸的也不一定非得设置一个很大的
α
α
. 不正确 **
* 选项4: 将CostFunction的值每次都打印出来,看有没有减小来确定我们的训练是不是有效,感觉这个选项是完全正确的废话. 正确 **
最后
以上就是瘦瘦书本为你收集整理的Week5_1Neural Networks LearningWeek5_1Neural Networks Learning的全部内容,希望文章能够帮你解决Week5_1Neural Networks LearningWeek5_1Neural Networks Learning所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复