Skip to content

Commit

Permalink
Fix fast.ai monitor (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
pitercl authored Mar 30, 2020
1 parent 6380531 commit dea2019
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions neptunecontrib/monitoring/fastai.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ class NeptuneMonitor(LearnerCallback):
neptune.init(qualified_project_name='USER_NAME/PROJECT_NAME')
with neptune.create_experiment():
monitor = NeptuneMonitor()
learn = create_cnn(data, models.resnet18,
metrics=accuracy,
callbacks=[neptune_monitor])
callbacks_fns=[NeptuneMonitor])
learn.fit_one_cycle(20, 1e-2)
Note:
you need to have the fastai library installed on your computer to use this module.
"""

def __init__(self, experiment=None, learn=None, prefix=''):
def __init__(self, learn=None, experiment=None, prefix=''):
self._exp = experiment if experiment else neptune
self._prefix = prefix
if learn is not None:
Expand All @@ -88,6 +87,9 @@ def on_epoch_end(self, **kwargs):
metric_values = kwargs['last_metrics']
metric_names = ['valid_last_loss'] + kwargs['metrics']
for metric_value, metric_name in zip(metric_values, metric_names):
if metric_value is None:
continue

metric_name = getattr(metric_name, '__name__', metric_name)
self._exp.send_metric(self._prefix + str(metric_name), float(metric_value))

Expand Down

0 comments on commit dea2019

Please sign in to comment.