Skip to content

Commit

Permalink
Change range(len) to enumerate (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
theonekeyg committed Apr 29, 2020
1 parent 9626881 commit 1affa2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchvision/datasets/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _find_classes(self, dir):
"""
classes = [d.name for d in os.scandir(dir) if d.is_dir()]
classes.sort()
class_to_idx = {classes[i]: i for i in range(len(classes))}
class_to_idx = {cls_name: i for i, cls_name in enumerate(classes)}
return classes, class_to_idx

def __getitem__(self, index):
Expand Down

0 comments on commit 1affa2e

Please sign in to comment.