NOTE: Each image in the dataset has size 28x28, so the data has size 28x28x32 (since batch_size is 32); kernelsize = 3 in the convolutional layer, and default stride = 1. To calculate output size of the convolution layer we use this formula: convolutionOutputSize = 1+ (inputSize - kernelSize)/stride = 1+ (28 - kernelSize)/stride The final output of the convolution layer, and therefore the input to the 1st linear layer will then have the following size: convolutionOutputSize x convolutionOutputSize x 32 2 Linear layers. The last linear layer is already defined. For the forward propogation function use F.relu as the activation function for the convolution layer and the first linear layer. The last linear layer and the activation function for it (softmax) are already written. CODE: class MyModel(nn.Module): def__init__(self): super(MyModel, self).__init__() # DEFINE CONVOLUTION LAYER HERE, CALL IT self.conv1 *** #self.conv1 = **complete this line** # DEFINE LINEAR LAYER 1 HERE, CALL IT self.d1 *** #self.d1 = **complete this line** self.d2 = nn.Linear(128,10) defforward(self, x): ## *** WRITE CONVOLUTION LAYER HERE *** x = x.flatten(start_dim = 1) # we use a flatten between the convolution and linear layers ## *** WRITE FIRST LINEAR LAYER HERE *** logits = self.d2(x) #10 class score out = F.softmax(logits, dim=1) return out

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

NOTE: Each image in the dataset has size 28x28, so the data has size 28x28x32 (since batch_size is 32); kernelsize = 3 in the convolutional layer, and default stride = 1. To calculate output size of the convolution layer we use this formula:

convolutionOutputSize = 1+ (inputSize - kernelSize)/stride = 1+ (28 - kernelSize)/stride

The final output of the convolution layer, and therefore the input to the 1st linear layer will then have the following size: convolutionOutputSize x convolutionOutputSize x 32

  1. 2 Linear layers. The last linear layer is already defined.

  2. For the forward propogation function use F.relu as the activation function for the convolution layer and the first linear layer. The last linear layer and the activation function for it (softmax) are already written.

 

CODE:

 

class MyModel(nn.Module):
def__init__(self):
super(MyModel, self).__init__()

# DEFINE CONVOLUTION LAYER HERE, CALL IT self.conv1 ***
#self.conv1 = **complete this line**

# DEFINE LINEAR LAYER 1 HERE, CALL IT self.d1 ***
#self.d1 = **complete this line**
 
self.d2 = nn.Linear(128,10)

defforward(self, x):
## *** WRITE CONVOLUTION LAYER HERE ***


x = x.flatten(start_dim = 1) # we use a flatten between the convolution and linear layers


 
## *** WRITE FIRST LINEAR LAYER HERE ***


logits = self.d2(x) #10 class score
out = F.softmax(logits, dim=1)
return out
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education