DeepChem

How to integrate W&B with DeepChem library.

The DeepChem library provides open source tools that democratize the use of deep-learning in drug discovery, materials science, chemistry, and biology. This W&B integration adds simple and easy-to-use experiment tracking and model checkpointing while training models using DeepChem.

DeepChem logging in 3 lines of code

logger = WandbLogger()
model = TorchModel(, wandb_logger=logger)
model.fit()

Report and Google Colab

Explore the Using W&B with DeepChem: Molecular Graph Convolutional Networks article for an example charts generated using the W&B DeepChem integration.

To dive straight into working code, check out this Google Colab.

Track experiments

Set up W&B for DeepChem models of type KerasModel or TorchModel.

Sign up and create an API key

An API key authenticates your machine to W&B. You can generate an API key from your user profile.

  1. Click your user profile icon in the upper right corner.
  2. Select User Settings, then scroll to the API Keys section.
  3. Click Reveal. Copy the displayed API key. To hide the API key, reload the page.

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.

    export WANDB_API_KEY=<your_api_key>
    
  2. Install the wandb library and log in.

    pip install wandb
    
    wandb login
    
pip install wandb
import wandb
wandb.login()
!pip install wandb

import wandb
wandb.login()

Log your training and evaluation data to W&B

Training loss and evaluation metrics can be automatically logged to W&B. Optional evaluation can be enabled using the DeepChem ValidationCallback, the WandbLogger will detect ValidationCallback callback and log the metrics generated.

from deepchem.models import TorchModel, ValidationCallback

vc = ValidationCallback()  # optional
model = TorchModel(, wandb_logger=logger)
model.fit(, callbacks=[vc])
logger.finish()
from deepchem.models import KerasModel, ValidationCallback

vc = ValidationCallback()  # optional
model = KerasModel(, wandb_logger=logger)
model.fit(, callbacks=[vc])
logger.finish()

Last modified February 13, 2025: a09c831