Skip to content

Commit 3f4c978

Browse files
committed
Change metric evaluations history
1 parent bbc0a82 commit 3f4c978

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

iaflow/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,13 @@ def clear_session(self):
431431
clear_session()
432432
gc.collect()
433433

434-
def plot_history(self, history, path):
434+
def __evaluate_metric(self, current = 0, target = 0, monitor = ''):
435+
if 'loss' in monitor.lower():
436+
return current < target
437+
438+
return current > target
439+
440+
def plot_history(self, history, path, monitor='val_loss'):
435441
train_loss = history.history['loss']
436442
train_acc = history.history['accuracy']
437443
val_loss = history.history['val_loss']
@@ -445,12 +451,14 @@ def plot_history(self, history, path):
445451
}
446452

447453
for idx in range(len(train_loss)):
448-
cur_val_acc = val_acc[idx]
449-
if cur_val_acc > results['val_acc']:
454+
curr_metric = history.history[monitor][idx]
455+
target = results[monitor]
456+
457+
if self.__evaluate_metric(curr_metric, target, monitor):
450458
results['train_loss'] = train_loss[idx]
451459
results['train_acc'] = train_acc[idx]
452460
results['val_loss'] = val_loss[idx]
453-
results['val_acc'] = cur_val_acc
461+
results['val_acc'] = val_acc[idx]
454462

455463
for key, value in results.items():
456464
print(f'{key}: {value}')

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setuptools.setup(
88
name="iaflow",
9-
version='2.1.14',
9+
version='2.1.15',
1010
author="Enmanuel Magallanes Pinargote",
1111
author_email="enmanuelmag@cardor.dev",
1212
description="This library help to create models with identifiers, checkpoints, logs and metadata automatically, in order to make the training process more efficient and traceable.",

0 commit comments

Comments
 (0)