C3W2B_Assignment Pix2Pix Error In Given Code?

image

transform = transforms.Compose([
    transforms.ToTensor(),
])

import torchvision
dataset = torchvision.datasets.ImageFolder("maps", transform=transform)

def train(save_model=False):
    dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)

From this code snippet, it seems that the code is loading images from a folder named “maps” and this folder contains subfolders for both training and validation. Isn’t this wrong, shouldn’t it just be from the train folder?

Training and validation happen both during training phase, so thats fine!

The training dataset is used to train the model’s parameters, the validation dataset is used to fine-tune hyperparameters and evaluate model performance during training, and the test dataset is used for evaluating the model’s performance on unseen data to gauge its generalization ability.

@JOSE_Paul, you’re right that in this assignment, we’re just looking at both the “train” and the “val” images together. The dataloader considers the “train” and “val” sub-folders to be classes, but as you probably noticed, in the code, we are just ignoring the second return result (the class) when we call the dataloader.

        for image, _ in tqdm(dataloader):

This is OK for this assignment, since the point of the assignment is to just focus on implementing the loss function, and we just need a set of images to work on. We don’t go through a separate validation step in this assignment, but just visually look at the images to get an idea of how our fake images compare with their real counterparts.

1 Like