neural networks and deep learning coursera week 2 quiz answers

Quiz - Neural Network Basics

1. In logistic regression given the input x, and parameters w € R". b € R, how do we generate the output g?

  • aWx+b).
  • a(Wx)
  • tanh(W x + b)
  • Wx+b

2. Which of these is the "Logistic Loss"?

3. Consider the Numpy array x:

x=np.array([[[1], [2], [3], [4]])

What is the shape of x?

  • (4,)
  • (1, 2, 2)
  • (2, 2, 1)
  • (2, 2)

4. Consider the following random arrays a and b, and c:

a = np.random.randn(3,3) # a.shape = (3,3)

b= np.random.randn(2,1) #b.shape = (2,1)

c=a+b

What will be the shape of c?

  • c.shape = (3,3)
  • c.shape = (2, 3, 3)
  • c.shape = (2, 1)
  • The computation cannot happen because it is not possible to broadcast more than one dimension

5. Consider the two following random arrays a and b:

a = np.random.randn(4, 3) # a.shape = (4, 3)

b = np.random.randn(1,3) # b.shape = (1, 3)

c = a*b

What will be the shape of c?

  • c.shape = (1, 3)
  • The computation cannot happen because the sizes don’t match.
  • The computation cannot happen because it is not possible to broadcast more than one dimension.
  • c.shape = (4, 3)

6. Suppose our input batch consists of 8 grayscale images, each of dimension 8x8. We reshape these images into feature column vectors x'. Remember that X= x(1)g(2) ... x8) . What is the dimension of X?

  • (64, 8)
  • (512, 1)
  • (8, 8, 8)
  • (8, 64)

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 = (150,150)
  • c.shape = (12288, 150)
  • The computation cannot happen because the sizes don’t match. It’s going to be “Error”!
  • C.Shape = (12288. 45)

Consider the following code snippet:

a.shape = (4,3)
b.shape = (4,1)

for i in range(3):
for j in range(4):
c[i][j] = a[j][i] + b[j]

How do you vectorize this?

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

9. Consider the code snippet:

a.shape = (3,3)
b.shape = (3,3)
C= a**2 + b.T**2

Which of the following gives an equivalent output for C?

  • for i in range(3):
    for j in range(3):
    c[i][j] = a[i][j]**2 + b[i][j]**2
  • for i in range(3):
    c[i] = a[i]**2 + b[i]**2
  • The computation cannot happen because the sizes don’t match. It’s going to be an “Error”!
  • for i in range(3):
    for i in range(3):
    c[i][j] = a[i][j]**2 + b[j][i]**2

10. Consider the following computational graph.

What is the output of J?

  • ab + bc + ac
  • (a – 1), (b + c)
  • (a + c), (b – 1)
  • (c – 1), (a + c)

Leave a Reply