Skip to content

Quickstart#

Open in Colab

pip install neptune-client
conda install -c conda-forge neptune-client
Installing through Anaconda Navigator

To find neptune-client, you may need to update your channels and index.

  1. In the Navigator, select Environments.
  2. In the package view, click Channels.
  3. Click Add..., enter conda-forge, and click Update channels.
  4. In the package view, click Update index... and wait until the update is complete. This can take several minutes.
  5. You should now be able to search for neptune-client.

    Note: The displayed version may be outdated. The latest version of the package will be installed.

Create a run#

  1. Create a script called hello_neptune.py.
  2. Copy and paste the below code to the script file.
hello_neptune.py
import neptune.new as neptune

# Create a Neptune run object
run = neptune.init_run(
    api_token=neptune.ANONYMOUS_API_TOKEN,  # (1)
    project="common/quickstarts",  # (2)
)

# Track metadata and hyperparameters by assigning them to the 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(10):
    run["train/accuracy"].log(epoch * 0.6)  # (3)
    run["train/loss"].log(epoch * 0.4)

# Log the final results
run["f1_score"] = 0.66

# Stop the connection and sync the data with Neptune
run.stop()
  1. The api_token argument is included to enable anonymous logging. Once you register, you should leave the token out of your script and instead save it as an environment variable.
  2. Projects in the common workspace are public and can be used for testing. To log to your own workspace, pass the full name of your Neptune project: workspace-name/project-name. For example, "ml-team/classification". To copy it, navigate to the project settingsProperties.
  3. Mocked code, so we can see the graph visualized in a Neptune chart.

Now that you have your Hello Neptune script ready, execute it from your terminal, Jupyter Lab, or other environments:

python hello_neptune.py

Click the link in the console output to open the run in Neptune.

Example link: https://app.neptune.ai/common/quickstarts/e/QUI-80914

Explore the results in Neptune#

Viewing all metadata of a run

In the left pane, you can see your data in the following sections:

  • All metadata - displays logged metadata in a folder-like structure.
  • Charts - visualizes the metrics as charts.
  • Monitoring - shows hardware consumption during the run execution.
  • Source code - records the code that was used for the run.

See in Neptune  See code on GitHub 

Congrats! You've learned how to connect Neptune to your code and explore the tracked run in the app.

Next steps#

  • Rerun the script with different parameters to track a few more runs, then click Compare runs in the very left pane to compare and visualize them.
  • To get the most out of Neptune, take the Neptune tutorial.
  • When you move on from Hello Neptune, take a moment to save your API token as an environment variable. This helps keep your API token secure, as you can omit the api_token parameter from your code.

Resources to check out

Back to top