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

Remove duplicate code #1125

Merged
merged 2 commits into from
Jul 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions torchvision/datasets/fakedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ class FakeData(VisionDataset):

def __init__(self, size=1000, image_size=(3, 224, 224), num_classes=10,
transform=None, target_transform=None, random_offset=0):
super(FakeData, self).__init__(None)
self.transform = transform
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be even better if you deleted both occurrences and passed transform and target_transform to the constructor of the parent class.

def __init__(self, root, transforms=None, transform=None, target_transform=None):

Copy link
Contributor Author

@zhiqwang zhiqwang Jul 16, 2019

Choose a reason for hiding this comment

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

Done. Thanks for this suggestion. In cifar.py, caltech.py etc, I didn't look for all datasets, is it necessary to pass transform and target_transform to the constructor? If yes, I'm appreciate to do this in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, this should be done in every dataset, since @fmassa implemented it in #872.

self.target_transform = target_transform
super(FakeData, self).__init__(None, transform=transform,
target_transform=target_transform)
self.size = size
self.num_classes = num_classes
self.image_size = image_size
self.transform = transform
self.target_transform = target_transform
self.random_offset = random_offset

def __getitem__(self, index):
Expand Down