原文翻译:深度学习测试题(L1 W2 测试题)
导语
本文翻译自deeplearning.ai的深度学习课程测试作业,近期将逐步翻译完毕,一共五门课。
翻译:黄海广
本集翻译Lesson1 Week 2:
Lesson1 Neural Networks and Deep Learning (第一门课 神经网络和深度学习)
Week 2 Quiz - Neural Network Basics(第二周测验 - 神经网络基础)
1.What does a neuron compute?(神经元节点计算什么?)
【 】 A neuron computes an activation function followed by a linear function (z = Wx + b)(神经元节点先计算激活函数,再计算线性函数(z = Wx + b))
【★】 A neuron computes a linear function (z = Wx + b) followed by an activation function(神经元节点先计算线性函数(z = Wx + b),再计算激活。)
【 】 A neuron computes a function g that scales the input x linearly (Wx +b)(神经元节点计算函数g,函数g计算(Wx + b))
【 】 A neuron computes the mean of all features before applying the output to an activation function(在将输出应用于激活函数之前,神经元节点计算所有特征的平均值)
Note: The output of a neuron is a = g(Wx + b) where g is the activation function (sigmoid, tanh, ReLU, …).(注:神经元的输出是a = g(Wx + b),其中g是激活函数(sigmoid,tanh,ReLU,…))
2. Which of these is the “Logistic Loss”?(下面哪一个是Logistic损失?)
【★】损失函数:
Note: We are using a cross-entropy loss function.(注:我们使用交叉熵损失函数。)
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像素的图像。如何将其重新转换为列向量?)
Answer(答):
x = img.reshape((32 * 32 * 3, 1))
4. Consider the two following random arrays “a” and “b”:(看一下下面的这两个随机数组“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的维度是多少?)
Answer(答):
c.shape = (2, 3)
b (column vector) is copied 3 times so that it can be summed to each column of a. Therefore, c.shape = (2, 3).( B(列向量)复制3次,以便它可以和A的每一列相加,所以:c.shape = (2, 3))
5. Consider the two following random arrays “a” and “b”:(看一下下面的这两个随机数组“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”的维度是多少?)
Answer(答):
The computation cannot happen because the sizes don’t match. It’s going to be “error”!(无法进行计算,因为大小不匹配。将会报错!)
Note:“*” operator indicates element-wise multiplication. Element-wise multiplication requires same dimension between two matrices. It’s going to be an error.(注:运算符 “*” 说明了按元素乘法来相乘,但是元素乘法需要两个矩阵之间的维数相同,所以这将报错,无法计算。)
6. Suppose you have input features per example. Recall that . What is the dimension of X?(假设你的每一个样本有个输入特征,想一下在 中,X的维度是多少?)
Answer(答):
Note: A stupid way to validate this is use the formula
when, then we have(请注意:一个比较笨的方法是当的时候,那么计算一下,所以我们就有:
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”:(看一下下面的这两个随机数组“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的维度是多少?)
Answer(答):
c.shape = (12288, 45), this is a simple matrix multiplication example.( 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?(请问要怎么把它们向量化?)
Answer(答):
c = a + b.T
9. Consider the following code:(看一下下面的代码:)
a = np.random.randn(3, 3)
b = np.random.randn(3, 1)
c = a * b
What will be c?(请问c的维度会是多少?)
Answer(答):
c.shape = (3, 3)
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)
.(这将会使用广播机制,b会被复制三次,就会变成(3,3),再使用元素乘法。所以:c.shape = (3, 3)
.)
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)
Answer(答):
J=(a - 1) * (b + c)
备注:公众号菜单包含了整理了一本AI小抄,非常适合在通勤路上用学习。
往期精彩回顾2019年公众号文章精选适合初学者入门人工智能的路线及资料下载机器学习在线手册深度学习在线手册AI基础下载(第一部分)备注:加入本站微信群或者qq群,请回复“加群”加入知识星球(4500+用户,ID:92416895),请回复“知识星球”
喜欢文章,点个在看
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!