mirror of
https://github.com/lucidrains/DALLE2-pytorch.git
synced 2025-12-19 09:44:19 +01:00
* Converted decoder trainer to use accelerate * Fixed issue where metric evaluation would hang on distributed mode * Implemented functional saving Loading still fails due to some issue with the optimizer * Fixed issue with loading decoders * Fixed issue with tracker config * Fixed issue with amp Updated logging to be more logical * Saving checkpoint now saves position in training as well Fixed an issue with running out of gpu space due to loading weights into the gpu twice * Fixed ema for distributed training * Fixed isue where get_pkg_version was reintroduced * Changed decoder trainer to upload config as a file Fixed issue where loading best would error
31 lines
596 B
Python
31 lines
596 B
Python
import time
|
|
import importlib
|
|
|
|
# time helpers
|
|
|
|
class Timer:
|
|
def __init__(self):
|
|
self.reset()
|
|
|
|
def reset(self):
|
|
self.last_time = time.time()
|
|
|
|
def elapsed(self):
|
|
return time.time() - self.last_time
|
|
|
|
# print helpers
|
|
|
|
def print_ribbon(s, symbol = '=', repeat = 40):
|
|
flank = symbol * repeat
|
|
return f'{flank} {s} {flank}'
|
|
|
|
# import helpers
|
|
|
|
def import_or_print_error(pkg_name, err_str = None):
|
|
try:
|
|
return importlib.import_module(pkg_name)
|
|
except ModuleNotFoundError as e:
|
|
if exists(err_str):
|
|
print(err_str)
|
|
exit()
|