Professional Documents
Culture Documents
(Lab4) CNN
(Lab4) CNN
2. Please download DogCat dataset at the link below. Then, complete custom dataset code
“DogCatDataset” (see below) using the filename and attached “test.csv” file. At that time, split the
training data to training and validation data on your own. Finally, train a CNN model using
training/validation data (Use “3_cnn_imagenet.py” in the attached files). Print train/val/test accuracy
and error graphs in every epoch.
https://www.kaggle.com/competitions/dogs-vs-cats
class DogCatDataset(data.Dataset):
# TODO:
# TODO:
def __len__(self):
# TODO:
3. Store the model with the highest validation accuracy (pth) and save the test accuracy of that
model.
5. Compare the performance with and without the pre-trained ResNet18 model attached
“pretrained_resnet18.pth”. You will need to update the model using the DogCat training/validation
data. At this time, you will need to change the number of class because the pretrained model was
trained with the data including 1000 classes. Please refer the code below.
...
state_dict = torch.load(args.pretrained_model)
model.load_state_dict(state_dict)
* do not set num_classes=1000