This integration is tested with numpy==1.19.5, torch==1.8.1, torchvision==0.10.0, and neptune-client==0.9.16.
You need minimal familiarity with PyTorch. Go through the PyTorch tutorial to get started.
Step 1: Initialize a Neptune Run
Place this code snippet at the beginning of your script or notebook cell
import neptune.new as neptune
run = neptune.init(project ='<YOUR_WORKSPACE/YOUR_PROJECT>',
This opens a new Run in Neptune that allows you to log various objects.
You need to authenticate yourself and open an existing project. Here is how:
You can use the api_token='ANONYMOUS' and project='common/pytorch-integration' to explore without having to create a Neptune account.
You can use namespace to helps you organize all your model training metadata into folders. For more see Namespace handler.
Step 2: Log config & hyperparameters
You can assign your configuration variables and hyperparameters to Fields of a Run using "=". There are a few benefits from doing this, precisely:
Makes it easier to read your code
And distinguish single value or AtomFields (i.e. hyperparameters) from a multi value or Series Fields (i.e.losses and metrics) which you see next.
To log metrics and losses use .log() method in your training loop:
for epoch inrange(epochs):
for i,(x, y)inenumerate(trainloader,0):
# Log batch loss
# Log batch accuracy
Step 4: Stop logging to the Neptune Run
Once you are done logging, you should stop tracking the run using the stop() method. This is needed only while logging from a notebook environment. While logging through a script, Neptune automatically stops tracking once the script has completed execution.
Step 5: Run your training script or notebook cell and monitor your training in Neptune UI
Run your script or notebook cell as you normally would.