參考https://zhuanlan.zhihu.com/p/31268885
1、What does a neuron compute?
- A neuron computes an activation function followed by a linear function (z = Wx + b)
- A neuron computes a linear function (z = Wx + b) followed by an activation function
- A neuron computes a function g that scales the input x linearly (Wx + b)
- A neuron computes the mean of all features before applying the output to an activation function
1、神經元計算什麼?
- 神經元先計算激活函數,再計算線性函數(z = Wx + b)
- 神經元先計算線性函數(z = Wx + b),再計算激活函數。(正確)
- 神經元計算函數g,函數g計算(Wx + b)。
- 在將輸出應用於激活函數之前,神經元計算所有特徵的平均值
===============================================================
2、Which of these is the “Logistic Loss”?以下哪個是邏輯迴歸損失函數?
- 。(正確)
參見2.3 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?
假設img是一個(32,32,3)數組,具有3個顏色通道:紅色、綠色和藍色的32x32像素的圖像。 如何將其轉換爲列向量?
- x = img.reshape((1,32 * 32 * 3))
- x = img.reshape((32 * 32 , 3))
- x = img.reshape((32 * 32 * 3, 1))。正確
- x = img.reshape((3,32 * 32 ))
參見2.16 關於 python / numpy 向量的說明
===============================================================
4、Consider the two following random arrays “a” and “b”: 有2個隨機數組a和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”? 請問數組c的維度是怎麼樣?
- c.shape = (3, 2)
- c.shape = (2, 1)
- c.shape = (2, 3)。(正確)
- The computation cannot happen because the sizes don’t match.It’s going to be “Error”!
參見2.15 Python 中的廣播。
B(列向量)複製3次,然後和A的每一列相加。
===============================================================
5、Consider the two following random arrays “a” and “b”:有2個隨機數組a和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”? 請問數組c的維度是怎麼樣?
- The computation cannot happen because the sizes don’t match.It’s going to be “Error”!(正確)
- c.shape = (4, 3)
- c.shape = (3, 3)
- c.shape = (4, 2)
數組按照元素相乘需要兩個矩陣之間的維數相同,但是a和b維度不同,所以這將報錯,無法計算。
===============================================================
6、Suppose you have n_x input features per example. Recall that . What is the dimension of X?
假設你的每一個實例有個輸入特徵,想一下在中,X的維度是多少?
- (m,1)
- (m,)
- (,m)。(正確)
- (1,m)
m個x向量橫向堆疊。x是包含個元素的列向量。
===============================================================
7、Recall that np.dot(a,b) performs a matrix multiplication on a and b, whereas a*b performs an element-wise multiplication.
回想一下,np.dot(a,b)
在a和b上執行矩陣乘法,而`a * b’執行元素方式的乘法。
Consider the two following random arrays “a” and “b”:
有2個隨機數組“a”和“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? 請問數組c的維度是怎麼樣?
- c.shape = (150, 150)
- The computation cannot happen because the sizes don’t match.It’s going to be “Error”!
- c.shape = (12288, 150)
- c.shape = (12288, 45)。(正確)
矩陣乘法,沒什麼好說的。
===============================================================
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? 如何向量化?
- c = a + b.T。(正確)
- c = a.T + b
- c = a + b
- c = a.T + b.T
c的維度(3,4),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?
- This will invoke broadcasting, so b is copied three times to become (3,3), and * is an element-wise product so c.shape = (3, 3).(正確)
- This will invoke broadcasting, so b is copied three times to become (3,3), and * invokes a matrix multiplication operation of 3x3 matrices so c will be (3, 3).
- This will multiply a 3x3 matrix a with a 3x1 vector, thus resulting in a 3x1 vector. That is, c.shape= (3, 1).
- 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).
數組按照元素相乘。使用廣播機制,b會被複制三次。
===============================================================
10、Consider the following computation graph. 觀察下面計算圖
What is the output J? J是什麼?
- J= (c - 1) * (b + a)
- J= (a - 1) * (b + c)。(正確)
- J= a * b + b * c + a * c
- J= (b - 1) * (c + a)
推導過程如下
J = u + v - w
= a * b + a * c - (b + c)
= a * (b + c) - (b + c)
= (a - 1) * (b + c)