Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, log_dir='./model_checkpoints',
filename='model-checkpoint_{}.ivis', epoch_interval=1):
super(ModelCheckpoint, self).__init__()
self.log_dir = log_dir
os.makedirs(log_dir, exist_ok=True)
self.filename = filename
self.epoch_interval = epoch_interval
self.epochs_since_last_save = 0
self.n_epochs_without_progress = n_epochs_without_progress
self.margin = margin
self.ntrees = ntrees
self.search_k = search_k
self.precompute = precompute
self.model_def = model
self.model_ = None
self.encoder = None
self.supervision_metric = supervision_metric
self.supervision_weight = supervision_weight
self.supervised_model_ = None
self.loss_history_ = []
self.annoy_index_path = annoy_index_path
self.callbacks = callbacks
for callback in self.callbacks:
if isinstance(callback, ModelCheckpoint):
callback = callback.register_ivis_model(self)
if build_index_on_disk is None:
self.build_index_on_disk = True if platform.system() != 'Windows' else False
else:
self.build_index_on_disk = build_index_on_disk
self.verbose = verbose