介绍
weights and bias是一个机器学习可视化分析工具
- 日志上传云端永久存储,便于分享不怕丢失
- 可以存管代码,数据集和模型的版本,随时复现
- 可以使用交互式表格进行case分析
- 可以自动化模型调参
核心功能:实验跟踪、版本管理、case分析、超参调优
实验跟踪
wandb提供了类似tensorboard的实验跟踪能力
- 模型配置超参数的记录
- 模型训练过程中loss, metric等各种指标的记录和可视化
- 图像的可视化
- 其他各种media
常用函数
- wandb.init()
- wandb.config
- wandb.log()
- wandb.log_artifact
代码实例
# Flexible integration for any Python script
import wandb
# 1. Start a W&B Run
wandb.init(project='my-project-name')
# 2. Save mode inputs and hyperparameters
config = wandb.config
config.learning_rate = 0.01
# Set up model and data
model, dataloader = get_model(), get_data()
# Model training goes here
# 3. Log metrics over time to visualize performance
wandb.log({"loss": loss})
# 4. Log an artifact to W&B
wandb.log_artifact(model)
版本管理
除了可以记录实验日志,进行可视化分析
wandb还能够将实验关联的数据集,代码和模型保存到wandb服务器
可以通过wandb.log_artifact方法来保存任务的关联的重要成果
例如dataset, code, model,并进行版本管理
artifact翻译为“工件”,是指软件卡发中产出的最终成果
# Save a model file from the current directory
wandb.save('model.h5')
# Save all files that currently exist containing the substring "ckpt"
wandb.save('../logs/*ckpt*')
# Save any files starting with "checkpoint" as they're written to
wandb.save(os.path.join(wandb.run.dir, "checkpoint*"))
case分析
利用Wanda.Table我们可以在wandb的dashboard进行交互式可视化的case分析
run = wandb.init(project="table-test")
my_table = wandb.Table(columns=["a", "b"], data=[["a1", "b1"], ["a2", "b2"]])
run.log({"Table Name": my_table})