# Deep Neural Networks with PyTorch Coursera Quiz Answers

## All Weeks Deep Neural Networks with PyTorch Coursera Quiz Answers

The course will teach you how to develop deep learning models using Pytorch. The course will start with Pytorch’s tensors and Automatic differentiation package. Then each section will cover different models starting off with fundamentals such as Linear Regression, and logistic/softmax regression. Followed by Feedforward deep neural networks, the role of different activation functions, normalization, and dropout layers. Then Convolutional Neural Networks and Transfer learning will be covered. Finally, several other Deep learning methods will be covered.

### Deep Neural Networks with PyTorch Week 01 Quiz Answers

#### Quiz 01: 1.1 Tensors 1D

Q1. Consider the following code:

`a = torch.tensor([10,9,8,7])`

What is the output of :

`a[1:3] `

- tensor([9,8])
- tensor([9,8,7])
- [9,8,7]

Q2. What does the method

`item()`

- perform
- gets a Python number from a tensor containing a single value
- returns a python list

#### Quiz 02 : 1.2 Two-Dimensional Tensors

Q1. How do you convert the following Pandas Dataframe to a tensor:

`df = pd.DataFrame({'A':[11, 33, 22],'B':[3, 3, 2]})`

- torch.tensor(df.values)
- torch.tensor(df)

Q2. what is the result of the following:

`A = torch.tensor([[0, 1, 1], [1, 0, 1]])`

`B = torch.tensor([[1, 1], [1, 1], [-1, 1]])`

`A_times_B = torch.mm(A,B)`

- tensor([[0, 2], [0, 2]])
- tensor([[0, 1], [1, 4]])

#### Quiz 03 :1.3 Derivatives in PyTorch

Q1. How would you determine the derivative of $ y = 2x^3+x $ at $x=1$

```
x = torch.tensor(1.0, requires_grad=True)
y = 2 * x ** 3 + x
y.backward()
x.grad
```

Q2. Try to determine partial derivative 𝑢u of the following function where 𝑢=2u=2 and 𝑣=1v=1: 𝑓=𝑢𝑣+(𝑢𝑣)**2 ** **

```
x = torch.tensor(1.0, requires_grad=True)
y = 2 * x ** 3 + x
y.backward()
x.grad
```

```
u = torch.tensor(2.0, requires_grad = True)
v = torch.tensor(1.0, requires_grad = True)
f = u * v + (u * v) ** 2
f.backward()
print("The result is ", v.grad)
```

### Deep Neural Networks with PyTorch Week 02 Quiz Answers

#### Quiz 01: Prediction in One Dimension

Q1. What’s wrong with the following class or custom module:

```
# Customize Linear Regression Class
class LR(nn.Module):
# Constructor
def __init__(self, input_size, output_size):
# Inherit from parent
super(LR, self).__init__()
linear = nn.Linear(input_size, output_size)
# Prediction function
def forward(self, x):
out = self.linear(x)
return out
```

- “super” is not needed
- “nn.Module” is not required
- “
**linea**r” should be**self.linear** - The code will run fine

Q2. Consider the following lines of code. How many Parameters does the object model have?`12from torch.nn import Linearmodel=Linear(in_features=1,out_features=1)`

- 1
- 2
- 3
- None of the above

#### Quiz 02: Linear Regression Training

Q1. In linear regression, the noise can best be characterized by :

- we add small values to the linear model
- we multiply small values to the linear model

Q2. An application of linear regression can be

- classify house as over priced
- Predicting housing prices (y) giving the size of the house (x)

#### Quiz 03: Loss

Q1. The following table shows some possible values of our parameter and and the value of the loss generated, what value would you select :

Q2.

Our linear function is a function of the:**1 point**

- x
- b
- w

### Deep Neural Networks with PyTorch Week 03 Quiz Answers

#### Quiz 01: Multiple Linear Regression Prediction

Q1. Consider the following code, including the bais. How many parameters does the object model have?

`model=nn.Linear(4,1) `

### 2.

Question 2

Consider the following code. How many rows and columns does the tensor yhat contain?

```
X=torch.tensor([[1.0,1.0,1],[1.0,2.0,1],[1.0,3.0,1],[1.0,3.0,1]])
model=nn.Linear(3,1)
yhat=model(X)
```

- 4,1
- 3,1
- 4,4

Q3. If the input to our linear regression object is of 10 dimensions, including the bias, how many variables does our cost or total loss function contain?

#### Quiz 02: Multiple Output Linear Regression

Q1. How many bias parameters will object **model** have?

```
class linear_regression(nn.Module):
def __init__(self,input_size,output_size):
super(linear_regression,self).__init__()
self.linear=nn.Linear(input_size,output_size)
def forward(self,x):
yhat=self.linear(x)
return yhat
model=linear_regression(3,10)
```

Preview will appear here…

Q2. What parameters do you have to change to the method backwards() when you train Multiple Output Linear Regression compared to regular Linear Regression?

- None of them
- You have to specify the number of the output variables
- All of them

### Deep Neural Networks with PyTorch Week 04 Quiz Answers

#### Quiz 01 :6.1 Softmax Function:Using Lines to Classify Data

Q1. How would you classify the purple point given the three lines used in a softmax classifier:

- yhat=0 or blue
- yhat=1 or red
- yhat=2 or green

Q2. Consider the following output of the lines used in the softmax function shown in the following table. What will be the value of yhat ?

- yhat=0
- yhat=1
- yhat=2

### Deep Neural Networks with PyTorch Week 05 Quiz Answers

#### Quiz: Deep Neural Networks

Q1. What kind of activation function is being used in the second hidden layer:

```
lass NetTanh(nn.Module):
# Constructor
def __init__(self, D_in, H1, H2, D_out):
super(NetTanh, self).__init__()
self.linear1 = nn.Linear(D_in, H1)
self.linear2 = nn.Linear(H1, H2)
self.linear3 = nn.Linear(H2, D_out)
# Prediction
def forward(self, x):
x = torch.sigmoid(self.linear1(x))
x = torch.tanh(self.linear2(x))
x = self.linear3(x)
return x
```

- tanh
- sigmoid

Q2. Consider the following code:

```
class Net(nn.Module):
# Constructor
def __init__(self, D_in, H1, H2, D_out):
super(Net, self).__init__()
self.linear1 = nn.Linear(D_in, H1)
self.linear2 = nn.Linear(H1, H2)
self.linear3 = nn.Linear(H2, D_out)
# Prediction
def forward(self,x):
x = torch.sigmoid(self.linear1(x))
x = torch.sigmoid(self.linear2(x))
x = self.linear3(x)
return x
model = Net(3,5,4,1)
```

How many hidden layers are there in this model?

### Deep Neural Networks with PyTorch Week 06 Quiz Answers

#### Quiz: 9.1 Convolution

Q1. How would you create a convolution object with a kernel size of 3 **1 point**

` conv= nn.Conv2d(in_channels=1, out_channels=1,kernel_size=3)`

`conv = nn.Conv2d(in_channels=3, out_channels=3,kernel_size=2)`

Q2. Consider a 3X3 input matrix or Tensor and a 2X2 kernel, after convolution the out but will be a square matrix, what is the size of one of the dimensions of the square matrix.

##### Deep Neural Networks with PyTorch Coursera Course Review:

In our experience, we suggest you enroll in the Deep Neural Networks with PyTorch Coursera and gain some new skills from Professionals completely free and we assure you will be worth it.

Deep Neural Networks with PyTorch course is available on Coursera for free, if you are stuck anywhere between quiz or graded assessment quiz, just visit Networking Funda to get Deep Neural Networks with PyTorch Coursera Quiz Answers.

##### Conclusion:

I hope this Deep Neural Networks with PyTorch Coursera Quiz Answers would be useful for you to learn something new from this Course. If it helped you then don’t forget to bookmark our site for more Coursera Quiz Answers.

This course is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisite courses.

Keep Learning!

#### Get all Course Quiz Answers of IBM AI Engineering Professional Certificate

Machine Learning with Python Coursera Quiz Answers

Introduction to Deep Learning & Neural Networks with Keras Quiz Answers

Introduction to Computer Vision and Image Processing Quiz Answers

Deep Neural Networks with PyTorch Coursera Quiz Answers

Building Deep Learning Models with TensorFlow Coursera Quiz Answers

AI Capstone Project with Deep Learning Coursera Quiz Answers