Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: 54 dataset #59

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

DRAFT: 54 dataset #59

wants to merge 4 commits into from

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.

@@ -21,7 +21,9 @@ class DequantizedDataset(torch.utils.data.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?

@@ -30,6 +32,13 @@ def __init__(
else:
self.dataset = pd.read_csv(dataset).values

#
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?

@@ -21,8 +21,9 @@ class DequantizedDataset(torch.utils.data.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.

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