1: What does a neuron compute?(神经元怎么进行计算)
A: A neuron computes an activation function followed by a linear function (z = wx + b),神经元在计算完线性函数 z = wx + b后在进行激活函数计算
B: A neuron computes the mean of all features before applying the output to an activation function
C: A neuron computes a linear function (z = Wx + b) followed by an activation function
D: A neuron computes a function g that scales the input x linearly (Wx + b)
答案: A,应该是C, 开始的时候翻译错了。 神经元是先进行线性计算,在进行激活函数计算。
2. Which of these is the "Logistic Loss"?
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,1))
B: x = img.reshape((1,32*32,*3))
C: x = img.reshape((3,32*32))
D: x = img.reshape((32*32,3))
答案是: D
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: c.shape = (2, 1)
B: c.shape = (3, 2)
C: c.shape = (2, 3)
D: The computation cannot happen because the sizes don't match. It's going to be "Error"!
答案是 C , 广播的原因, b会自己复制3次后 和 a 一样的维度后相加
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: c.shape = (4, 3)
D: The computation cannot happen because the sizes don't match. It's going to be "Error"!
答案是:D , 运算符 “*” 说明了按元素乘法来相乘,但是元素乘法需要两个矩阵之间的维数相同,所以这将报错,无法计算
6. Suppose you have input features per example. Recall that X=[x^(1), x^(2)…x^(m)] . What is the dimension of X?
A: (1,m)
B: (m,1)
C: (nx,m)
D: (m,nx)
答案是 C
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: c.shape = (150,150)
B: c.shape = (12288, 150)
C: The computation cannot happen because the sizes don't match. It's going to be "Error"!
D: c.shape = (12288, 45)
答案是 D , 简单的矩阵 相乘
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.T + b.T
B: c = a.T + b
C: c = a + b.T
D: c = a + b
答案是 C
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)
答案是 A
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)
答案是: B