Installation
conda create -n wandb_tutorial python==3.8
conda activate wandb_tutorial
pip install -r requirements.txt
Quick usage
-
Create a
wandb
account through this link. -
Go into your chosen example directory
cd coin_toss
or
cd CNN-MNIST
- Edit the
train.py
script: replaceENTITY
by yourwandb
username.
wandb.init(
entity="ENTITY",
project="wandb_tutorial",
config=args,
save_code=True,
)
- Run the
train.py
script with default or your chosen arguments.coin_toss
example:
python train.py --prob 0.75
wandb
in 5 easy steps
Use - Create a
wandb
account. - Install
wandb
commandline tool.
pip install wandb
- Import
wandb
import wandb
- Initialize
wandb
, replacingENTITY
with yourwandb
account username.
wandb.init(
entity="ENTITY",
project="wandb_tutorial",
config=args,
save_code=True,
)
- Log to
wandb
wandb.log(
{
"train/loss": loss,
}
)
FAQs
How do I keep track of my model gradients?
wandb.watch(model)
What if I'm already logging to tensorboard?
wandb
can automatically log your tensorboard metrics. All you need to do is add the sync_tensorboard
flag to the wandb
initialization. Example:
wandb.init(
entity="ENTITY",
project="wandb_tutorial",
config=args,
save_code=True,
sync_tensorboard=True,
)
What if I run wandb in a notebook?
Everything will work nicely but you need to add wandb.finish()
at the very bottom of your notebook (after you're done with training/evaluation.)
Will wandb
work with my code?
wandb
is framework agnostic. You can add it yourself as we demonstrate in this tutorial or rely on wandb
integrations.
For instance, to use wandb
with HuggingFace
, you need only do:
from transformers import TrainingArguments, Trainer
args = TrainingArguments(... , report_to="wandb")
trainer = Trainer(... , args=args)