Skip to content

Commit fd9a6a7

Browse files
noqqaqqNicolasHug
andauthored
Enumerate over dataset instead of simple loop (#2407)
Co-authored-by: noqqaqq <noqqaqq@users.noreply.github.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
1 parent 5b804b8 commit fd9a6a7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

beginner_source/data_loading_tutorial.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ def __getitem__(self, idx):
165165

166166
fig = plt.figure()
167167

168-
for i in range(len(face_dataset)):
169-
sample = face_dataset[i]
170-
168+
for i, sample in enumerate(face_dataset):
171169
print(i, sample['image'].shape, sample['landmarks'].shape)
172170

173171
ax = plt.subplot(1, 4, i + 1)
@@ -356,9 +354,7 @@ def __call__(self, sample):
356354
ToTensor()
357355
]))
358356

359-
for i in range(len(transformed_dataset)):
360-
sample = transformed_dataset[i]
361-
357+
for i, sample in enumerate(transformed_dataset):
362358
print(i, sample['image'].size(), sample['landmarks'].size())
363359

364360
if i == 3:

0 commit comments

Comments
 (0)