Question: answer the questions and print the output with the solution and Screen Shot The output and the code I want picture Screen Shot. To do
answer the questions and print the output with the solution and Screen Shot The output and the code I want picture Screen Shot. To do this, you will need a data set to train the model. The data set for this lab can be obtained from GitHub repository. You can download it from here
Search in google nickmccullub catsanddogs github
Here's what the repository contains:
A folder called trainingdata that holds images of cats and images of dogs
A folder called testdata that contains images of cats and images of dogs
A folder called predictions that image of a cat and image of a dog. We will use the images in this predictions folder to make single predictions using our trained model later in this tutorial.
Every image in this data set is a jpg file.
The code
import numpy as np
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
traininggenerator ImageDataGenerator
rescale
shearrange
zoomrange
horizontalflip True
trainingset traininggenerator.flowfromdirectorytrainingdata',
targetsize
batchsize
classmode 'binary'
testgenerator ImageDataGeneratorrescale
testset testgenerator.flowfromdirectorytestdata',
targetsize
batchsize
classmode 'binary'
cnn tfkeras.models.Sequential
cnnaddtfkeras.layers.ConvDfilters kernelsize activation'relu', inputshape
cnnaddtfkeras.layers.MaxPoolDpoolsize strides
cnnaddtfkeras.layers.ConvDfilters kernelsize activation'relu'
cnnaddtfkeras.layers.MaxPoolDpoolsize strides
cnnaddtfkeras.layers.Flatten
cnnaddtfkeras.layers.Denseunits activationrelu
cnnaddtfkeras.layers.Denseunits activation'sigmoid'
cnncompileoptimizer 'adam', loss 'binarycrossentropy', metrics accuracy
cnnfitx trainingset, validationdata testset, epochs
from tensorflow.keras.preprocessing import image
testimage image.loadimgpredictionscatordogjpg targetsize
testimage image.loadimgpredictionscatordogjpg targetsize
testimage image.imgtoarraytestimage
testimage image.imgtoarraytestimage
testimage npexpanddimstestimage axis
testimage npexpanddimstestimage axis
printcnnpredicttestimage
printcnnpredicttestimage
questions
Please print the output of traininggenerator.flowfromdirectory as an image here Mark
Please print the output of testgenerator.flowfromdirectory as an image here Mark
What will be the add command if we wanted to have feature detectors, with a kernel size of x Marks
What will be the add command if we wanted to have a max pooling layer which reduces the size of the image by a factor of Marks
Please share the output of the first, fifth and tenth epoch of training as an image here marks
printcnnpredicttestimage and
printcnnpredicttestimage
What is the output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
