neptunecontrib.monitoring.keras

Module Contents

Classes

NeptuneMonitor(experiment=None, prefix=’‘)

Logs Keras metrics to Neptune.

neptunecontrib.monitoring.keras.msg = keras package not found.
As Keras is now part of Tensorflow you should install it by running

pip install tensorflow

class neptunecontrib.monitoring.keras.NeptuneMonitor(experiment=None, prefix='')[source]

Bases: tensorflow.keras.callbacks.Callback

Logs Keras metrics to Neptune.

Goes over the last_metrics and smooth_loss after each batch and epoch and logs them to Neptune.

See the example experiment here https://ui.neptune.ai/shared/keras-integration/e/KERAS-23/logs

Parameters
  • experimentneptune.Experiment, optional: Neptune experiment. If not provided, falls back on the current experiment.

  • prefix – str, optional: Prefix that should be added before the metric_name and valid_name before logging to the appropriate channel. Defaul is empty string (‘’).

Example

Initialize Neptune client:

import neptune

neptune.init(api_token='ANONYMOUS',
             project_qualified_name='shared/keras-integration')

Create Neptune experiment:

neptune.create_experiment(name='keras-integration-example')

Instantiate the monitor and pass it to callbacks argument of model.fit():

from neptunecontrib.monitoring.keras import NeptuneMonitor

model.fit(x_train, y_train,
          epochs=PARAMS['epoch_nr'],
          batch_size=PARAMS['batch_size'],
          callbacks=[NeptuneMonitor()])

Note

You need to have Keras or Tensorflow 2 installed on your computer to use this module.

_log_metrics(self, logs, trigger)[source]
on_batch_end(self, batch, logs=None)[source]

A backwards compatibility alias for on_train_batch_end.

on_epoch_end(self, epoch, logs=None)[source]

Called at the end of an epoch.

Subclasses should override for any actions to run. This function should only be called during TRAIN mode.

Parameters
  • epoch – Integer, index of epoch.

  • logs – Dict, metric results for this training epoch, and for the validation epoch if validation is performed. Validation result keys are prefixed with val_.