incorporated from dadav / pwnagotchi

This commit is contained in:
scifijunk 2021-12-08 12:11:29 -06:00 committed by GitHub
parent 38e7eaae73
commit 7142e2bfd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,8 +45,17 @@ def load(config, agent, epoch, from_disk=True):
if from_disk and os.path.exists(config['path']):
logging.info("[ai] loading %s ..." % config['path'])
start = time.time()
a2c.load(config['path'], env)
logging.debug("[ai] A2C loaded in %.2fs" % (time.time() - start))
try:
a2c.load(config['path'], env)
except AssertionError as as_err:
from fnmatch import fnmatch
# Sometimes the model breaks...
if not fnmatch(str(as_err), '* same * space as the model *'):
raise as_err
else:
logging.warning("[ai] Model could not be loaded. Using new model.")
else:
logging.debug("[ai] A2C loaded in %.2fs" % (time.time() - start))
else:
logging.info("[ai] model created:")
for key, value in config['params'].items():