Skip to content

Quickstart#

Open in Colab

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

To find neptune, 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.

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

Note: On Bioconda, there is a "neptune" package available which is not the neptune.ai client library. Make sure to specify the "conda-forge" channel when installing neptune.ai.

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

# Create a Neptune run object
run = neptune.init_run(
    project="your-workspace-name/your-project-name",  # (1)!
    api_token="YourNeptuneApiToken",  # (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"].append(epoch * 0.6)  # (3)!
    run["train/loss"].append(epoch * 0.4)

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

# Stop the connection and synchronize the data with the Neptune servers
run.stop()
  1. The full project name. For example, "ml-team/classification". To copy it, navigate to the project settingsProperties.
  2. In the Neptune app, click your avatar and select Get your API token. When you're done testing, save your API token as an environment variable instead of putting it here in the code!
  3. Mocked code, so we can see the graph visualized in a Neptune chart.
How do I find my API token?

In the top-right corner of the Neptune app, click your avatar and select Get your API token.

You can copy your token from the dialog that opens. It's very long – make sure to copy and paste it in full!

hello_neptune.py
import neptune

# Create a Neptune run object
run = neptune.init_run(
    project="common/quickstarts",  # (1)!
    api_token=neptune.ANONYMOUS_API_TOKEN,  # (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"].append(epoch * 0.6)  # (3)!
    run["train/loss"].append(epoch * 0.4)

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

# Stop the connection and synchronize the data with the Neptune servers
run.stop()
  1. 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.
  2. 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.
  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.

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.
  • 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.
  • To get the most out of Neptune, take the Neptune tutorial. It walks you through all of the above plus the central Neptune features.

Other resources to check out