https://wandb.ai/site

wandb这个库可以帮助我们跟踪实验,记录运行中的超参数和输出指标,可视化结果并共享结果
支持keras,tensorflow,scikit-learn,pytorch等

  1. import wandb
  2. # 1. Start a new run
  3. wandb.init(project="gpt-3")
  4. # 2. Save model inputs and hyperparameters
  5. config = wandb.config
  6. config.learning_rate = 0.01
  7. # 3. Log gradients and model parameters
  8. wandb.watch(model)
  9. for batch_idx, (data, target) in
  10. enumerate(train_loader):
  11. if batch_idx % args.log_interval == 0:
  12. # 4. Log metrics to visualize performance
  13. wandb.log({"loss": loss})

下面是wandb的重要的工具:Dashboard:跟踪实验,可视化结果;Reports:分享,保存结果;Sweeps:超参调优;Artifacts:数据集和模型的版本控制。

Tools

  1. Dashboard: Track experiments, visualize results
  2. Reports: Save and share reproducible findings
  3. Sweeps: Optimize models with hyperparameter tuning
  4. Artifacts: Dataset and model versioning, pipeline tracking

一. 极简Lite Pipeline(6步用起来wandb)

https://wandb.ai/chuanqi/test
1 首先安装库:
pip install wandb

2 创建账户:
wandb login

3 import库再初始化:
# Inside my model training code
import wandb wandb.init(project=“my-project”)

4 声明超参数:
wandb.config.dropout = 0.2
wandb.config.hidden_layer_size = 128

5 记录日志:
def my_train_loop():
for epoch in range(10):
loss = 0 # change as appropriate :)
wandb.log({‘epoch’: epoch, ‘loss’: loss})

6 保存文件(默认在wandb.run.dir中):
# by default, this will save to a new subfolder for files associated
# with your run, created in

wandb.run.dir (which is ./wandb by default)
wandb.save(“mymodel.h5”) # you can pass the full path to the Keras model API model.save(os.path.join(wandb.run.dir, “mymodel.h5”))

使用wandb以后,模型输出,log和要保存的文件将会同步到cloud。