Answered step by step
Verified Expert Solution
Question
1 Approved Answer
dataset = datasets.ImageFolder ( root = 'path _ to _ your _ data', transform = transform ) I changed to train _ data = datasets.ImageFolder
dataset datasets.ImageFolderroot'pathtoyourdata', transformtransform
I changed to traindata datasets.ImageFolderroottrain transformtransform
testdata datasets.ImageFolderroottest transformtransform Given that I have folder 'test' : images and 'train': images. Each folder will have subfolder 'Action', 'Comedy', 'Horror', 'Romance', which includes many poster films images for that type. Using ImageFolder load the data into your notebook and create a dataLoader from the data. Using the same CNN architecture defined in the here class CNNnnModule:
def initself:
superCNN selfinit
self.conv nnSequential
nnConvd
inchannels # channel, typical for grayscale images
outchannels
kernelsize #size of the convolutional filter is x
stride # the filter moves one pixel at a time
padding # adding of pixels to the input on all sides, ensuring that the output has the same width and height as the input.
nnReLU
nnMaxPooldkernelsize
self.conv nnSequential
nnConvd
nnReLU
nnMaxPoold
# fully connected layer, output classes
self.out nnLinear
def forwardself x:
x self.convx
x self.convx
# flatten the output of conv to batchsize,
x xviewxsize
output self.outx
return output train the model on this
new dataset. Determine the test accuracy of the model.
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