Logging and managing experiment results

Log and manage data in Neptune via Neptune client (Python and R clients are available).

What is neptune-client?

Neptune client is an open source Python library that serves three purposes:

  1. log machine learning experiments,

  2. update existing experiment with new data and visualizations,

  3. download experiment data from Neptune to local machine.

It is designed to be:

  • lightweight: low setup effort,

  • generic: capable of logging any kind of machine learning work

  • straightforward: user defines what to keep track of during experiment to use.

You can log experiments from anywhere (local machine, cluster, cloud, Colab, etc.) and they will be tracked in the same, standardized way. You will be able to quickly compare experiments run by you on your workstation with experiments run on AWS by your team-mate.

What you need to add to your code to start logging

Bare minimum are one import and two methods:

import neptune

# Set project
neptune.init('my_workspace/my_project')

# Create experiment
neptune.create_experiment()

These are usually just copy&paste into your existing project code.

Note

Remember to create project and setup API token before you create an experiment using snippet above.

Now, that the experiment is created you can start logging metrics, losses, images, model weights or whatever you feel relevant to keep track of in your experiment.

Overall idea for logging is to use methods similar to this:

neptune.log_metric('acc', 0.95)

Generic recipe being:

neptune.log_X('some_name', some_value)

Where X could be metric, artifact, chart, pickle, etc. Check the logging section for a complete list.

Note

If you work in Notebooks, you need to place neptune.stop (reference docs: stop()) at the very end of your experiment to make sure that everything will be closed properly.

Note that you are still able to update an experiment that was closed before.

Essential Neptune client concepts

Project and Experiment are two important entities in Neptune.

Basic snippet below, sets project and creates new experiment in that project.

# Set project
neptune.init('my_workspace/my_project')

# Create new experiment
neptune.create_experiment()

Project

It is a collection of Experiments, created by user (or users) assigned to the project.

You can log experiments to the project or fetch all experiments that satisfy some criteria.

# Set project and get project object
project = neptune.init('my_workspace/my_project')

# Use project to create experiment
project.create_experiment()

# Use project to get experiments data from the project
project.get_leaderboard(state=['succeeded'])

Learn more about downloading data from Neptune. Check also, Project to use in your Python code.

Experiment

Experiment is everything that you log to Neptune, beginning at neptune.create_experiment() and ending when script finishes or when you explicitly stop the experiment with neptune.stop (reference docs: stop()).

Creating experiment is easy:

# Set project
neptune.init('my_workspace/my_project')

# Create new experiment
neptune.create_experiment()

You can now log various data to the experiment including metrics, losses, model weights, images, predictions and much more. Have a look at the complete list of what you can log to the experiment

Besides logging data, you can also download experiment data to you local machine or update an existing experiment even when it’s closed.

Note

neptune.log_metric('some_name', some_value) is for tracking all numeric values to Neptune (metric, loss, score, variances, etc.). Learn, what else can be tracked to experiment from this list.

Learn more about the Experiment object and how to use it in your Python code.