神经网络与深度学习(Quiz 2)

这篇博客包含了关于神经网络与深度学习的多项选择题解析,涉及神经元计算、损失函数、数组重塑、矩阵运算及计算图等方面的知识点。
摘要由CSDN通过智能技术生成

1。What does a neuron compute?

A. A neuron computes the mean of all features before applying the output to an activation function

B. A neuron computes a linear function (z = Wx + b) followed by an activation function

C. A neuron computes an activation function followed by a linear function (z = Wx + b)

D. A neuron computes a function g that scales the input x linearly (Wx + b)
解析:
一个神经元为计算一个线性函数,并紧跟着一个激活函数(Sigmoid或ReLu)

2。Which of these is the “Logistic Loss”?
A. L(i)(y^(i),y(i))=−(y(i)log(y^(i))+(1−y(i))log(1−y^(i)))
B. L(i)(y^(i),y(i))=max(0,y(i)−y^(i))
C. L(i)(y^(i),y(i))=∣y(i)−y^(i)∣2
D. L(i)(y^(i),y(i))=∣y(i)−y^(i)∣
解析:
logistic损失函数为交叉熵损失,而不是平方差(会导致非凸求解)

3。Suppose img is a (32,32,3) array, representing a 32x32 image with 3 color channels red, green and blue. How do you reshape this into a column vector?

A. x = img.reshape((32*32,3))

B. x = img.reshape((3,32*32))

C. x = img.reshape((32*32*3,1))

D. x = img.reshape((1,32*32,*3))
解析:
reshape为列向量
4。Consider the two following random arrays “a” and “b”:

a = np.random.randn(2, 3) # a.shape = (2, 3)
b = np.random.randn(2, 1) # b.shape = (2, 1)
c = a + b

What will be the shape of “c”?

A. The computation cannot happen because the sizes don’t match. It’s going to be “Error”!

B. c.shape = (3, 2)

C. c.shape = (2, 3)

D. c.shape = (2, 1)
解析:
python广播规则,自动填充为(m*n)

5。Consider the two following random arrays “a” and “b”:

a = np.random.randn(4, 3) # a.shape = (4, 3)
b = np.random.randn(3, 2) # b.shape = (3, 2)
c = a*b

What will be the shape of “c”?

A. c.shape = (3, 3)

B. c.shape = (4,2)

C. The computation cannot happen because the sizes don’t match. It’s going to be “Error”!

D. c.shape = (4, 3)
解析:∗如果连接两个矩阵的话,那么表示这两个矩阵要同大小,然后是对位点积。否则就要引发广播,而这个矩阵大小不相容,因此引发错误。而如果是numpy.dot的话,则是按照矩阵乘法规则算的。
因此这里是按照对位点积的形式,必须保证两个矩阵相同。否则会报错。

6。 Suppose you have nx input features per example. Recall that X=[x(1)x(2)…x(m)]. What is the dimension of X?

A. (m,1)

B. (1,m)

C. (m,nx)

D. (nx,m)
7。Recall that “np.dot(a,b)” performs a matrix multiplication on a and b, whereas “a*b” performs an element-wise multiplication.
Consider the two following random arrays “a” and “b”:

a = np.random.randn(12288, 150) # a.shape = (12288, 150)
b = np.random.randn(150, 45) # b.shape = (150, 45)
c = np.dot(a,b)

What is the shape of c?

A. The computation cannot happen because the sizes don’t match. It’s going to be “Error”!

B. c.shape = (12288, 45)

C. c.shape = (12288, 150)

D. c.shape = (150,150)
解析:numpy.dot对应叉乘,普通的*对应点乘

8。Consider the following code snippet:

# a.shape = (3,4)
# b.shape = (4,1)

for i in range(3):
  for j in range(4):
    c[i][j] = a[i][j] + b[j]

How do you vectorize this?

A. c = a + b.T

B. c = a.T + b.T

C. c = a.T + b

D. c = a + b

解析:由代码可知最终c的大小与a一样,所以不用a转置,又由广播机制可知,要使b转置才行。因此选。

9。Consider the following code:

a = np.random.randn(3, 3)
b = np.random.randn(3, 1)
c = a*b

What will be c? (If you’re not sure, feel free to run this in python to find out).

A. This will invoke broadcasting, so b is copied three times to become (3,3), and ∗ is an element-wise product so c.shape will be (3, 3)

B. This will invoke broadcasting, so b is copied three times to become (3, 3), and ∗ invokes a matrix multiplication operation of two 3x3 matrices so c.shape will be (3, 3)

C. This will multiply a 3x3 matrix a with a 3x1 vector, thus resulting in a 3x1 vector. That is, c.shape = (3,1).

D. It will lead to an error since you cannot use “*” to operate on these two matrices. You need to instead use np.dot(a,b)

解析:此处的两个矩阵实相容的,因此会引发广播。而*指的是对位点积。
10。
Consider the following computation graph.
这里写图片描述

What is the output J?
A. J = (c - 1)*(b + a)

B. J = (a - 1) (b + c)*

C. J = a*b + b*c + a*c

D. J = (b - 1) * (c + a)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值