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

0-sized dataset produces an error when given to DataLoader #206

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions tutorials/01-basics/pytorch_basics/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
class CustomDataset(torch.utils.data.Dataset):
def __init__(self):
# TODO
# 1. Initialize file paths or a list of file names.
# 1. Initialize file paths or a list of file names.
pass
def __getitem__(self, index):
# TODO
Expand All @@ -146,13 +146,15 @@ def __getitem__(self, index):
# 3. Return a data pair (e.g. image and label).
pass
def __len__(self):
# You should change 0 to the total size of your dataset.
return 0
# You should change 0 to something unequal to 0
# (e.g. the total size of your dataset),
# if you want this file to run without errors
return 0

# You can then use the prebuilt data loader.
# You can then use the prebuilt data loader.
custom_dataset = CustomDataset()
train_loader = torch.utils.data.DataLoader(dataset=custom_dataset,
batch_size=64,
batch_size=64,
shuffle=True)


Expand All @@ -167,7 +169,7 @@ def __len__(self):
for param in resnet.parameters():
param.requires_grad = False

# Replace the top layer for finetuning.
# Replace the top layer for finetuning.??
resnet.fc = nn.Linear(resnet.fc.in_features, 100) # 100 is an example.

# Forward pass.
Expand Down