Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Template code below: ###add lines to import modules as needed ## def build _ model 1 ( ) : model = None # Add code
Template code below:
###add lines to import modules as needed
##
def buildmodel:
model None # Add code to define model
return model
def buildmodel:
model None#add code to define model
return model
def buildmodel:
model None #add code to define model
##this one should use the functional API so you can create the residual connections
return model
def buildmodelk:
model None # add code to define model
return model
#nio training or dataset construction should happen over this line
if name main:
##########
##add code here to load the CIFAR data set
######
## build and train model
model buildmodel
#compaile and train model
##build, compile and train model DS convolutions
model buildmodel
### repeate for model and your best subl params model
We're going to examine a convolutional neural network CNN used for classifying images in
the CIFAR dataset.
A Each input image is pixels with redgreenblue channels for a total size of
B The layers are as follows:
Conv D: filters, kernel, stridein both dimensions "same" padding
BatchNorm
Conv D: filters, kernel, stridein both dimensions "same" padding
BatchNorm
Conv D: filters, kernel, stridein both dimensions "same" padding
BatchNorm
Four more pairs of ConvDBatchnorm, just like the last, except with no striding
option so stride defaults to
Conv D: filters, kernel, in both dimensions "same" padding
BatchNorm
MaxPooling, pooling size, stride
Flatten
Dense aka Fully Connected units.
BatchNorm
Dense aka Fully Connected units
Use a spreadsheet or a script to calculate for each layer the number of parameters, the
number of multiplyaccumulate operations, and the output size. Turn in a pdf showing a
table of parameter and mac counts per layer, as well as the spreadsheet or script you used
to calculate it
The next steps will be turned in on GitHub. Copy the file hwtemplate.py to
hwcomplete.py for your work.
The automatic grading scripts will assume you used the filename hwcomplete.py so
please follow this instruction precisely.
Create a function named buildmodelabove the if line, which implements
the above model in Keras. Use your function to build the model and, name it 'model Use
the summary method to check your parameter count and output size calculations. Make
sure to 'compile' it
Load the CIFAR set and split the training set into a training and validation subset.
Your training, test, and validation sets should be in variables named, respectively:
trainimages, trainlabelstestimages, testlabelsvalimages, vallabels
Train for epochs. What is the training, validation, and test accuracy at the end of
training?
INCLUDE Did you observe any overfitting? Should the model train for longer, shorter, or
about that number of epochs.
Take or find a picture of something that is one of the output classes
airplane"automobile,"bird,"cat,'deer,"dog,'frog,"horse,"ship,"truck' Save it as a png or jpg
crop andor rescale it to pixels, and run your classifier on it Name the
croppedscaled image "testimageclassname.ext" where classname is one of the output
classes listed and 'ext' is the appropriate filename extension jpg or png
INCLUDE Does it correctly label the picture?
Repeat steps with a model where all convolutional layers except for the first one are
replaced with depthwiseseparable convolutions. Name this model 'model and build it
with a function called "buildmodel
For example, a layer
Conv D: filters, kernel, stridein both dimensions "same" padding
Would become either
SeparableConv D: filters, kernel, stridein both dimensions
"same" padding
OR
Depthwise Conv D: kernel, stridein both dimensions "same"
padding, usebiasFalse
Disable the bias here, because applying a bias to both sublayers is redundant
ConvD: filters edit kernel, stride
Note: Striding by twice would effectively stride by
Note: padding does not matter for a kernel.
Only the convolutionn would include the activation eg "relu"
INCLUDE For this model, did you observe any overfitting? Should the model train for longer,
shorter, or about that number of epochs.
Create a function that builds a rd model, with the same structure as the first model
standard convolutions rather than separable convolution but add dropout layers after the
convolutions and residual connections aka skip connections around every two
convolutional blocks a "block" here refers to a convolution layer, batchnorm, and dropout
Start the skip connections after the first convolution layer, because there is no benefit to
delivering gradients all the way back to the inputs. The building function should be called
buildmodel and the model should be named model Also note that here you will need
to use the functional API B rather than the Sequential
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started