Hello World

Source code on GitHub

Results in Neptune

Notebook in Colab

See example code

See results

Run example

Introduction

This guide will show you how to:

  • Connect Neptune to your script and create the first run,

  • Log metrics to Neptune and see metrics and charts in the UI.

By the end of it, you will see metadata tracked to your first run in Neptune!

If you are using R, go read this.

Before you start

Make sure you meet the following prerequisites before starting:

  • Have Python 3.6+ installed

You can run this how-to on Google Colab with zero setup.

Just click on the Run example in Colab link on the top of the page.

Step 1 - Install neptune-client

Go to the command line of your operating system and run the installation command:

pip
conda
pip
pip install neptune-client
conda
conda install -c conda-forge neptune-client

Here is more help about installation.

Step 2 - Create a hello_world.py

Create a python script called hello_world.py and copy the code below to it:

hello_world.py

import neptune.new as neptune
run = neptune.init(project='#', api_token='#') # your credentials
# Track metadata and hyperparameters of your run
run["JIRA"] = "NPT-952"
run["algorithm"] = "ConvNet"
params = {
"batch_size": 64,
"dropout": 0.2,
"learning_rate": 0.001,
"optimizer": "Adam"
}
run["parameters"] = params
# Track the training process by logging your training metrics
for epoch in range(100):
run["train/accuracy"].log(epoch * 0.6)
run["train/loss"].log(epoch * 0.4)
# Log the final results
run["f1_score"] = 0.66

Step 3 - Add your credentials

To log metadata to Neptune you need to pass your credentials to the neptune.init() method.

run = neptune.init(project='#', api_token='#') # your credentials

project

project argument has the format workspace_name/project_name

To find it:

  1. Go to the Neptune UI

  2. Go to your project

  3. Open Settings

  4. Open Properties

  5. Copy the project name

api_token

To find it:

  1. Go to the Neptune UI

  2. Open User settings toggle in upper right

  3. Click Get Your API token

  4. Copy your API token

How to find your Neptune API token

For example:

run = neptune.init(project='funky_steve/timeseries',
api_token='eyJhcGlfYW908fsdf23f940jiri0bn3085gh03riv03irn')

Step 4 - Run your script and explore results

Now that you have your script ready you can run it from your terminal, Jupyter Lab, or other environments.

python hello_world.py

Click on the link in the terminal or notebook or go directly to the Neptune app.

The link should look like this one:

https://app.neptune.ai/o/common/org/colab-test-run/e/COL-72/all

Step 5 - See the results in Neptune UI

See metrics you logged in Logs, Charts, and hardware consumption in the Monitoring sections of the Neptune UI.

Conclusions

You’ve learned how to:

  • Install neptune-client,

  • Connect Neptune to your Python script and create a run,

  • Log metrics to Neptune,

  • Explore your metrics in All metadata and Charts sections,

  • See hardware consumption during the run execution in the Monitoring section.

Source code on GitHub

Results in Neptune

Notebook in Colab

See example code

See results

Run example

What’s next?