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

drop_last when loading the dataset is necessary. #3

Open
yyotta opened this issue Nov 7, 2022 · 0 comments
Open

drop_last when loading the dataset is necessary. #3

yyotta opened this issue Nov 7, 2022 · 0 comments

Comments

@yyotta
Copy link

yyotta commented Nov 7, 2022

The number of images in the mnist dataset is 60,000. At this time, if you set the batch size to 100 or any other value that can make 60,000 be divisible, that is OK. However, if you set other batch sizes that are commonly used, such as 256, 512, etc., it may lead to the wrong dimension of the last batch (96) and noise data (batch-size). So drop_last should be set when loading the dataset.
That is:
train_loader = torch.utils.data.DataLoader(dataset=train_dataset, batch_size=bs, shuffle=True)
-> train_loader = torch.utils.data.DataLoader(dataset=train_dataset, batch_size=bs, shuffle=True, drop_last=True)

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

No branches or pull requests

1 participant