Skip to content

Commit

Permalink
refactor inf_loop wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
SunQpark committed May 27, 2019
1 parent ae2e1e8 commit 257fbf8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ def write_json(content, fname):
json.dump(content, handle, indent=4, sort_keys=False)

def inf_loop(data_loader):
'''
wrapper function to make pytorch data loader loops endlessly.
'''
''' wrapper function for endless data loader. '''
for loader in repeat(data_loader):
for data, target in loader:
yield data, target
yield from loader

class Timer:
def __init__(self):
Expand All @@ -38,4 +35,3 @@ def check(self):

def reset(self):
self.cache = datetime.now()

0 comments on commit 257fbf8

Please sign in to comment.