From 912f0401bd81b43076bd49df26968fdb7b1ef4db Mon Sep 17 00:00:00 2001
From: Peter Steinbach
Date: Wed, 4 Mar 2020 14:41:59 +0100
Subject: [PATCH 1/2] 0-sized dataset produces an error when given to
DataLoader
---
tutorials/01-basics/pytorch_basics/main.py | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/tutorials/01-basics/pytorch_basics/main.py b/tutorials/01-basics/pytorch_basics/main.py
index 744400c2..fe099a96 100644
--- a/tutorials/01-basics/pytorch_basics/main.py
+++ b/tutorials/01-basics/pytorch_basics/main.py
@@ -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
@@ -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)
@@ -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.
From f9dd7b1acec2402eb5b90396fe99682fb67ffc9d Mon Sep 17 00:00:00 2001
From: Peter Steinbach
Date: Wed, 4 Mar 2020 14:41:59 +0100
Subject: [PATCH 2/2] 0-sized dataset produces an error when given to
DataLoader
---
tutorials/01-basics/pytorch_basics/main.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tutorials/01-basics/pytorch_basics/main.py b/tutorials/01-basics/pytorch_basics/main.py
index 744400c2..d2247353 100644
--- a/tutorials/01-basics/pytorch_basics/main.py
+++ b/tutorials/01-basics/pytorch_basics/main.py
@@ -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
@@ -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)