Skip to main content
PyTorch Geometric (PyG) is a library for geometric deep learning, and Weights & Biases works with it for visualizing graphs and tracking experiments. This guide shows you how to authenticate to Weights & Biases, install the wandb library, visualize PyG graphs with PyVis or Plotly, and log training metrics from your PyG workflows. Use it to track experiments and share graph visualizations in Weights & Biases. After you install PyTorch Geometric, follow these steps to get started.

Sign up and create an API key

An API key authenticates your machine to Weights & Biases. You can generate an API key from your user profile.
For a more streamlined approach, go to User settings and create an API key. Copy the API key immediately and save it in a secure location such as a password manager.
  1. Click the account selector in the upper-right corner.
  2. Select User settings, then scroll to the API keys section.

Install the wandb library and log in

To install the wandb library locally and log in:
  1. Set the WANDB_API_KEY environment variable to your API key. Replace values enclosed in <> with your own:
  2. Install the wandb library and log in.

Visualize the graphs

After you log in, you can begin sending graph visualizations and run data to Weights & Biases. You can save details about the input graphs, including number of edges, number of nodes, and more. Weights & Biases supports logging Plotly charts and HTML panels, so you can also log any visualizations you create for your graph to Weights & Biases. The following sections show two common approaches: PyVis for interactive HTML visualizations and Plotly for chart-based visualizations.

Use PyVis

The following snippet shows how to do that with PyVis and HTML.
Interactive graph visualization

Use Plotly

To use Plotly to create a graph visualization, first convert the PyG graph to a networkx object. Then create Plotly scatter plots for both nodes and edges. Use the following snippet for this task.
A visualization created using the example function and logged inside a W&B Table.

Log metrics

In addition to graph visualizations, you can use Weights & Biases to track your experiments and related metrics, such as loss functions, accuracy, and more. Add the following lines to your training loop:
hits@K metrics over epochs
With graph visualizations and training metrics logged to Weights & Biases, you can compare runs and share results from your PyG experiments in your Weights & Biases workspace.

More resources

The following W&B reports show PyG in action:
Last modified on October 23, 2026