Skip to content

API reference: Keras integration#

You can use a Neptune callback to capture model training metadata when using TensorFlow with Keras.

Related

For an in-depth tutorial, see IntegrationsWorking with Keras.


NeptuneCallback#

Captures model training metadata and logs them to Neptune.

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

Note

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

Parameters

Name         Type Default Description
run Run - An existing run reference, as returned by neptune.init_run().
base_namespace str, optional training Namespace under which all metadata logged by the Neptune callback will be stored.
log_model_diagram bool, optional False Save the model visualization. Requires pydot to be installed, otherwise it will silently skip saving the diagram.
log_on_batch bool, optional False Log the metrics also for each batch, not only each epoch.

Examples

# Create a run
import neptune.new as neptune
run = neptune.init_run(project="workspace-name/project-name")  # (1)

# Instantiate the callback
from neptune.new.integrations.tensorflow_keras import NeptuneCallback
neptune_callback = NeptuneCallback(
    run=run,
)

# Pass the callback to the "callbacks" argument of model.fit()
model.fit(
    x_train, y_train, callbacks=[neptune_callback]
)
  1. The full project name. For example, "ml-team/classification". To copy it, navigate to the project settingsProperties.

Log with additional options:

import pydot
import neptune.new as neptune
from neptune.new.integrations.tensorflow_keras import NeptuneCallback

run = neptune.init_run()

neptune_callback = NeptuneCallback(
    run=run,
    base_namespace="visualizations",  # set a custom namespace name
    log_model_diagram=True,
    log_on_batch=True,
)

...
Back to top