Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!