Hello World

Introduction

This guide will show you how to:

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

  • Log metrics to Neptune and explore them in the UI.

By the end of it, you will run your first run and see it in Neptune!

Before you start

Make sure you meet the following prerequisites before starting:

  • Have Python 3.x installed

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

Just click on the Run in Google 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.

If you are using R, go read this.

Step 2 - Create a quickstart.py

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

quickstart.py

import neptune.new as neptune
run = neptune.init(project='common/quickstarts',
api_token='ANONYMOUS')
# 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

Instead of logging data to the public project ‘common/onboarding’ as an anonymous user ‘neptuner’ you can log it to your own project:

  1. Pass the token to the neptune.init() method: api_token='YOUR_API_TOKEN'.

  2. Pass the project to the neptune.init() method: project='my_workspace/my_project'.

For example:

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

Step 3 - Run your script and explore results

Now that you have your script ready you can run it and see results in Neptune.

Run your script from the terminal or Jupyter notebook

python quickstart.py

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

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 Logs and Charts sections,

  • See hardware consumption during the run execution.

What’s next?

Now that you know how to create runs and log metrics you can learn: