【深度学习吴恩达】神经网络和深度学习--第三周课后测验及编程作业

测验题

4 . You are building a binary classifier for recognizing cucumbers (y=1) vs. watermelons (y=0).Which one of these activation functions would you recommend using for the output layer?(您正在构建一个识别黄瓜( y = 1)与西瓜( y = 0)的二元分类器。 你会推荐哪一种激活函数
用于输出层? )

【 】 ReLU
【 】 Leaky ReLU
【★】 sigmoid
【 】 tanh

Note: The output value from a sigmoid function can be easily understood as a probability.(注意:来自 sigmoid 函数的输出值可以很容易地理解为概率。 )

Sigmoid outputs a value between 0 and 1 which makes it a very good choice for binary classification.You can classify as 0 if the output is less than 0.5 and classify as 1 if the output is more than 0.5. It can be done with tanh as well but it is less convenient as the output is between -1 and 1.(Sigmoid 输出的值介于 0 和 1 之间,这使其成为二元分类的一个非常好的选择。 如果输出小于 0.5,则可以将其归类为 0,如果输出大于 0.5,则归类为 1。 它也可以用 tanh 来完成,但是它不太方便,因为输出在 -1 和 1 之间。 )

大家需要熟悉四种激活函数的话,这里提供一个比较详细的介绍文章。 深入理解深度学习中的激活函数

5 . Consider the following code:(看一下下面的代码: )

A = np.random.randn(4,3)
B = np.sum(A, axis = 1, keepdims = True)

What will be B.shape?(请问 B.shape 的值是多少?)
B.shape = (4, 1)

we use (keepdims = True) to make sure that A.shape is (4,1) and not (4, ). It makes our code more rigorous.(我们使用( keepdims = True)来确保 A.shape 是(4,1)而不是(4,),它使我们的代码更加严格。 )

关于 keepdims 参数的使用我自己找了一篇博客个人感觉不错,大家如果像我一样是个 numpy 小白的话可以看看哦~ numpy.mean,sum,max,min (keepdims=True)的理解

7*. Logistic regression’s weights w should be initialized randomly rather than to all zeros,because if you initialize to all zeros, then logistic regression will fail to learn a useful decision boundary because it will fail to “break symmetry”, True/False?(Logistic 回归的权重 w 应该随机初始化,而不是全零,因为如果初始化为全零,那么逻辑回归将无法学习到有用的决策边界,因为它将无法“破坏对称性”,是正确的吗? )

【 】 True(正确)
【★】 False(错误)

Note: Logistic Regression doesn’t have a hidden layer. If you initialize the weights to zeros, the first example x fed in the logistic regression will output zero but the derivatives of the Logistic Regression depend on the input x (because there’s no hidden layer) which is not zero. So at the second iteration, the weights values follow x’s distribution and are different from each other if x is not a constant vector.(Logistic 回归没有隐藏层。 如果将权重初始化为零,则 Logistic 回归中的第一个样本 x 将输出零,但 Logistic 回归的导数取决于不是零的输入 x(因为没有隐藏层)。 因此,在第二次迭代中,如果 x 不是常量向量,则权值遵循 x 的分布并且彼此不同。 )

8 . You have built a network using the tanh activation for all the hidden units. You initialize the weights to relative large values, using np.random.randn(…,…)*1000. What will happen?(您已经为所有隐藏单元使用 tanh 激活建立了一个网络。 使用 np.random.randn(…, …) * 1000 将权重初始化为相对较大的值。 会发生什么? )

【 】 It doesn’t matter. So long as you initialize the weights randomly gradient descent is not affected by whether the weights are large or small.(这没关系。 只要随机初始化权重,梯度下降不受权重大小的影响。 )
【 】 This will cause the inputs of the tanh to also be very large, thus causing gradients to also become large. You therefore have to set 伪 to be very small to prevent divergence; this will slow down learning.(这将导致 tanh 的输入也非常大,因此导致梯度也变大。 因此,您必须将 α 设置得非常小以防止发散; 这会减慢学习速度。 )
【 】 This will cause the inputs of the tanh to also be very large, causing the units to be “highly activated” and thus speed up learning compared to if the weights had to start from small values.(这会导致 tanh 的输入也非常大,导致单位被“高度激活”,从而加快了学习速度,而权重必须从小数值开始。 )
【★】 This will cause the inputs of the tanh to also be very large, thus causing gradients to be close to zero. The optimization algorithm will thus become slow.(这将导致 tanh 的输入也很大,因此导致梯度接近于零, 优化算法将因此变得缓慢。 )

Note:tanh becomes flat for large values, this leads its gradient to be close to zero. This slows down the optimization algorithm.(注: tanh 对于较大的值变得平坦,这导致其梯度接近于零。 这减慢了优化算法。 )

编程题

1、吴恩达老师英文题目下载链接(个人觉得阅读一下吴老师原题目也是有帮助的)

链接:https://pan.baidu.com/s/129etFGse1yCqx9mWczHQVg
提取码:h518

2、相关编程素材(数据集,py 文件等)下载链接 https://github.com/EvanMi/angleDeepLearning/tree/master/angle_01_week_03/Planar%20data%20classification%20with%20one%20hidden%20layer

3、何宽中文解释博客地址(在翻译吴老师英文的基础上添加了一些改动,包括代码) https://blog.csdn.net/u013733326/article/details/79702148

总结

测验题部分:对神经网络输入输出数据的矩阵表示形式了解的不够透彻,矩阵的维度也不够理解。需要继续强化知识。

在理解代码时参考了以下博客:
1. sklearn库的安装教程
2.【数字的可视化:python画图之散点图sactter函数详解】

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

早知晓

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值