Neural Networks and Deep Learning week2 Neural Network Basics

看别人见解违法coursera荣誉,看懂和做对是两码事
What does a neuron compute?

  • A neuron computes a linear function (z = Wx + b) followed by an activation function
  • A neuron computes the mean of all features before applying the output to an activation function
  • A neuron computes an activation function followed by a linear function (z = Wx + b)
  • A neuron computes a function g that scales the input x linearly (Wx + b)

神经元做什么,前半部分线性回归,后半部分非线性化变换(激活函数)

Which of these is the "Logistic Loss"?

希望你还记得熵, Y=-ylogy-(1-y)log(1-y)

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?

  • x = img.reshape((32*32*3,1))
  • x = img.reshape((3,32*32))
  • x = img.reshape((1,32*32,*3))
  • x = img.reshape((32*32,3))

图片如何变换,我们经常用的是列向量,所以 32*32*3,1,  默认列向量各领域通用

Consider the two following random arrays "a" and "b":What will be the shape of "c"?

a = np.random.randn(2, 3) # a.shape = (2, 3)
b = np.random.randn(2, 1) # b.shape = (2, 1)
c = a + b

  • c.shape = (3, 2)
  • c.shape = (2, 3)
  • The computation cannot happen because the sizes don't match. It's going to be "Error"!
  • c.shape = (2, 1)

python有广播的性质,(2,3)广播性质就是方便 矩阵加常数

Consider the two following random arrays "a" and "b":What will be the shape of "c"?

a = np.random.randn(4, 3) # a.shape = (4, 3)
b = np.random.randn(3, 2) # b.shape = (3, 2)
c = a*b

  • c.shape = (3, 3)
  • The computation cannot happen because the sizes don't match. It's going to be "Error"!
  • c.shape = (4, 3)
  • c.shape = (4,2)

np.dot和 * 是有区别的,一个是矩阵乘法,一个是数乘,这两个大小不匹配,没法点对点乘法

Suppose you have n_xnx​ input features per example. Recall that X = [x^{(1)} x^{(2)} ... x^{(m)}] What is the dimension of X?

(m,1)

(1,m)

(n_x, m)

(m,n_x)

x是列向量,X写成这样,那就只能是nx(x向量的特征数),m(x向量的个数)

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":What is the shape of c?

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)

  • c.shape = (12288, 150)
  • The computation cannot happen because the sizes don't match. It's going to be "Error"!
  • c.shape = (150,150)
  • c.shape = (12288, 45)

矩阵乘法 前行*后列,前面的列数=后面的行数,大小前行数*后列数

Consider the following code snippet:How do you vectorize this?

# 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]

  • c = a.T + b.T
  • c = a.T + b
  • c = a + b.T
  • c = a + b

有问题建议画图,画图是一个好习惯,可以捋清自己的思路

Consider the following code:What will be c? (If you’re not sure, feel free to run this in python to find out).

a = np.random.randn(3, 3)
b = np.random.randn(3, 1)
c = a*b

  • 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)
  • 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)
  • 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)

python 的广播性质

Consider the following computation graph.

0.

第 10 个问题

Consider the following computation graph. What is the output J?

 

  • J = (c - 1)*(b + a)
  • J = (a - 1) * (b + c)
  • J = a*b + b*c + a*c
  • J = (b - 1) * (c + a)

基础计算,都不需要看书的,毕竟都没涉及到偏导的重要公式

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值