参考https://zhuanlan.zhihu.com/p/31268885
1、神经元计算什么?
===============================================================
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像素的图像。 如何将其转换为列向量?
参见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的维度是怎么样?
参见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的维度是怎么样?
数组按照元素相乘需要两个矩阵之间的维数相同,但是a和b维度不同,所以这将报错,无法计算。
===============================================================
6、Suppose you have n_x input features per example. Recall that X = [ x ( 1 ) , x ( 2 ) … x ( m ) ] X=[x^{(1)}, x^{(2)}…x^{(m)}] X=[x(1),x(2)…x(m)]. What is the dimension of X?
假设你的每一个实例有 n x n_x nx个输入特征,想一下在 X = [ x ( 1 ) , x ( 2 ) … x ( m ) ] X=[x^{(1)}, x^{(2)}…x^{(m)}] X=[x(1),x(2)…x(m)]中,X的维度是多少?
m个x向量横向堆叠。x是包含 n x n_x nx个元素的列向量。
===============================================================
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的维度是怎么样?
矩阵乘法,没什么好说的。
===============================================================
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的维度(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?
数组按照元素相乘。使用广播机制,b会被复制三次。
===============================================================
10、Consider the following computation graph. 观察下面计算图
What is the output J? J是什么?
推导过程如下
J = u + v - w
= a * b + a * c - (b + c)
= a * (b + c) - (b + c)
= (a - 1) * (b + c)