From 9fa772c36a9ded8dce019c237803962abb7af2e2 Mon Sep 17 00:00:00 2001 From: Sniffleupagus <129890632+Sniffleupagus@users.noreply.github.com> Date: Wed, 28 Feb 2024 09:58:41 -0500 Subject: [PATCH] Automatically remove invalid ai parameters leftover from tensorflow Ease transition from old Pwnagotchi running tensor flow to new running torch, but automatically dumping the invalid parameters. Signed-off-by: Sniffleupagus <129890632+Sniffleupagus@users.noreply.github.com> --- pwnagotchi/ai/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pwnagotchi/ai/__init__.py b/pwnagotchi/ai/__init__.py index dd1c549a..24d798a5 100644 --- a/pwnagotchi/ai/__init__.py +++ b/pwnagotchi/ai/__init__.py @@ -23,6 +23,12 @@ def load(config, agent, epoch, from_disk=True): from stable_baselines3 import A2C logging.debug("[AI] A2C imported in %.2fs" % (time.time() - start)) + # remove invalid ai.parameters leftover from tensor_flow, if present + for key in [ 'alpha', 'epsilon', 'lr_schedule' ]: + if key in config['params']: + logging.info("Removing legacy ai parameter %s" % key); + del config['params'][key] + start = time.time() from stable_baselines3.a2c import MlpPolicy logging.debug("[AI] MlpPolicy imported in %.2fs" % (time.time() - start))