This commit is contained in:
xuhongzuo 2023-09-22 12:09:27 +08:00
commit d60f6d38d4
1 changed files with 11 additions and 1 deletions

View File

@ -19,7 +19,7 @@ from ray.air import session, Checkpoint
from ray.tune.schedulers import ASHAScheduler
from functools import partial
from deepod.utils.utility import get_sub_seqs, get_sub_seqs_label
import pickle
class BaseDeepAD(metaclass=ABCMeta):
"""
@ -518,6 +518,16 @@ class BaseDeepAD(metaclass=ABCMeta):
def load_ray_checkpoint(self, best_config, best_checkpoint):
return
def save_model(self, path):
with open(f"{path}.pkl", mode="wb") as f:
pickle.dump(self, f)
def load_model(self, path):
model = None
with open(f"{path}.pkl", mode="rb") as f:
model = pickle.load(f)
return model
@staticmethod
def set_seed(seed):
torch.manual_seed(seed)