Skip to content

Conversation

giorgiapitteri
Copy link
Collaborator

@giorgiapitteri giorgiapitteri commented Jun 25, 2024

PR for implementing a dataset with the right label associated to the image.

Previously the getitem method returned only the MNISt image with a dummy label always set to 0. Now the correct label is return.

Changes done for MNIST dataset.

TODO: do the same for the FashionMNist Dataset.


def __init__(
self,
dataset: T.Union[os.PathLike, torch.utils.data.Dataset, np.ndarray],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also specify here that dataset can be a torch.Tensor as well?


#
self.dataset = self.dataset.to(device)
if not isinstance(labels, torch.Tensor):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If dataset is a torch.utils.data.Dataset we don't need labels right? It automatically has a getitem method that returns the data and the label. So I would need to add a check here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think The baseclass getitem method is going to fail if the dataset is only a np array or a torch.Tensor. I understand there is the correct implementation in the derived class but maybe here we would need to put a check or raise an error?


def __init__(
self,
dataset: T.Union[os.PathLike, torch.utils.data.Dataset, np.ndarray],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to have a dataset object like a dictionary with images/labels? Otherwise I would renamed this "images" instead of dataset since we now have the labels object as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants