skip to Main Content
Comet Launches Kangas, an Open Source Data Analysis, Exploration and Debugging Tool for Machine Learning.

New Integration: Comet + Catalyst

We’re excited to announce another excellent and powerful integration with Comet — Catalyst! This integration allows you to leverage Comet’s logging capabilities while using the Catalyst framework to structure your Deep Learning Experiment runs

About Catalyst

Catalyst is a PyTorch framework for Deep Learning R&D. It focuses on reproducibility, rapid experimentation, and codebase reusability so you can create something new rather than write yet another train loop. The Catalyst library incorporates research best practices so users can focus on building models and not worry about writing boilerplate code.

About the Integration

Catalyst now ships with a dedicated CometLogger. With a slight modification (3 lines) of your Catalyst training code, you can now log metrics, hyperparameters, source code and much more from your runs to the Comet UI.

Once you’ve set up your account and configured your Comet API Key within your project, simply pass the CometLogger to your Catalyst Trainer and you’re good to go! You’ll then also be able to take advantage of Comet’s rich visualization capabilities

import comet_ml

import os
import torch
from torch import nn, optim
from torch.utils.data import DataLoader

from catalyst import dl
from catalyst.data import ToTensor
from catalyst.contrib.datasets import MNIST
from torch.utils.data import DataLoader


model = nn.Sequential(nn.Flatten(), nn.Linear(28 * 28, 10))
criterion = nn.CrossEntropyLoss()

logger = dl.CometLogger()

hparams = {"lr": 1.0e-3, "batch_size": 32}
optimizer = optim.Adam(model.parameters(), lr=hparams["lr"])
loaders = {
    "train": DataLoader(
        MNIST(os.getcwd(), train=True, download=True, transform=ToTensor()),
        batch_size=hparams["batch_size"],
    ),
    "valid": DataLoader(
        MNIST(os.getcwd(), train=False, download=True, transform=ToTensor()),
        batch_size=hparams["batch_size"],
    ),
}

runner = dl.SupervisedRunner(
    input_key="features", output_key="logits", target_key="targets", loss_key="loss"
)
# model training
runner.train(
    model=model,
    criterion=criterion,
    optimizer=optimizer,
    loaders=loaders,
    hparams=hparams,
    num_epochs=1,
    callbacks=[
        dl.AccuracyCallback(
            input_key="logits", target_key="targets", topk_args=(1, 3, 5)
        ),
        dl.PrecisionRecallF1SupportCallback(
            input_key="logits", target_key="targets", num_classes=10
        ),
    ],
    logdir="./logs",
    valid_loader="valid",
    valid_metric="loss",
    minimize_valid_metric=True,
    verbose=True,
    load_best_on_end=True,
    loggers={"comet": logger},
)

Getting Started

Getting started with this integration is really easy —

The following resources should help you start logging Catalyst runs to Comet in no time:

  • Colab Notebook — Our Notebook is ready to run, but you can also create a copy if you’d like to modify it.
  • Catalyst GitHub Repo — Need a crash course on Catalyst? Check out this GitHub repo for the basics and a whole lot more.
  • A free Comet account: Building with Comet is absolutely free — unlimited public and private projects, 100GB of storage, hyperparameter search, and more.
Dhruv | Comet ML

Dhruv Nair

Data Scientist at comet.ml
Back To Top