Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

dataset = datasets.ImageFolder ( root = 'path _ to _ your _ data', transform = transform ) I changed to train _ data = datasets.ImageFolder

dataset = datasets.ImageFolder(root='path_to_your_data', transform=transform)
I changed to train_data = datasets.ImageFolder(root='./train', transform=transform)
test_data = datasets.ImageFolder(root='./test', transform=transform). Given that I have 2 folder 'test' : 240 images and 'train': 960 images. Each folder will have 4 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 CNN(nn.Module):
def __init__(self):
super(CNN, self).__init__()
self.conv1= nn.Sequential(
nn.Conv2d(
in_channels=1, # 1 channel, typical for grayscale images
out_channels=16,
kernel_size=5, #size of the convolutional filter is 5x5
stride=1, # the filter moves one pixel at a time
padding=2, # adding of 2 pixels to the input on all sides, ensuring that the output has the same width and height as the input.
),
nn.ReLU(),
nn.MaxPool2d(kernel_size=2),
)
self.conv2= nn.Sequential(
nn.Conv2d(16,32,5,1,2),
nn.ReLU(),
nn.MaxPool2d(2),
)
# fully connected layer, output 10 classes
self.out = nn.Linear(32*7*7,10)
def forward(self, x):
x = self.conv1(x)
x = self.conv2(x)
# flatten the output of conv2 to (batch_size, 32*7*7)
x = x.view(x.size(0),-1)
output = self.out(x)
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago