Skip to content

Instantly share code, notes, and snippets.

# Imports
import tensorflow as tf
from tensorflow.keras.layers import *
from tensorflow.keras.models import *
import numpy as np
import wandb
from wandb.keras import WandbCallback
@ayulockin
ayulockin / wandb_retinanet_callback.py
Created August 4, 2022 06:27
A custom Keras callback that can log the validation data as W&B Tables and use the same to visualize model predictions.
import wandb
import tensorflow as tf
from keras_cv import bounding_box
class WandbTablesBuilder:
"""
Utility class that contains useful methods to create W&B Tables,
and log it to W&B.
"""
@ayulockin
ayulockin / wandb_metrics_logger.py
Created August 30, 2022 08:44
Manual test for new W&B Keras Metrics Logger.
import tensorflow as tf
import wandb
from wandb.keras import WandBMetricsLogger
with wandb.init(project="mnist", job_type="dev-wandb-metrics-logger"):
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
import tensorflow as tf
import wandb
from wandb.keras import (
# WandBMetricsLogger,
WandbModelCheckpoint,
# WandbGradientLogger,
# ModelLogger,
# FLOPsLogger,
)
@ayulockin
ayulockin / lora.py
Last active August 18, 2023 11:38
Configure lit-gpt train function to start logging metrics to W&B
# Demonstrative changes to this file: https://github.com/Lightning-AI/lit-gpt/blob/main/finetune/lora.py
from lightning.pytorch.loggers import WandbLogger
def setup(
data_dir: Path = Path("data/alpaca"),
checkpoint_dir: Path = Path("checkpoints/stabilityai/stablelm-base-alpha-3b"),
out_dir: Path = Path("out/lora/alpaca"),
precision: Optional[str] = None,