forked from DimplesL/Deeplearning.ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
C1W2_Quiz_Neural_Network_Basics.txt
56 lines (45 loc) · 1.91 KB
/
C1W2_Quiz_Neural_Network_Basics.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Quiz Week 2
1.What does a neuron compute?
A neuron computes a linear function (z = Wx + b) followed by an activation function
2.Which of these is the "Logistic Loss"?
L(i)(y^(i),y(i))=y(i)log(y^(i))+(1−y(i))log(1−y^(i))
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?
x = img.reshape((32*32*3,1))
4.Consider the two following random arrays "a" and "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.shape = (2, 3)
5.Consider the two following random arrays "a" and "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"?
The computation cannot happen because the sizes don't match. It's going to be "Error"!
6.Suppose you have nx input features per example. Recall that X=[x(1)x(2)...x(m)]. What is the dimension of X?
(nx,m)
7.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":
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.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
9.Consider the following code:
a = np.random.randn(3, 3)
b = np.random.randn(3, 1)
c = a*b
What will be c? (If you’re not sure, feel free to run this in python to find out).
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)
10.Consider the following computation graph.
What is the output J?
J = (a - 1) * (b + c)