0
0
MLOpsdevops~5 mins

Weights and Biases overview in MLOps - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you train machine learning models, you want to keep track of how well they perform and what settings you used. Weights and Biases helps you save this information automatically so you can compare and improve your models easily.
When you want to record your model training results without writing extra code.
When you need to compare different versions of your machine learning models.
When you want to share your training progress and results with your team.
When you want to visualize metrics like accuracy and loss over time.
When you want to save your model files and training data in one place.
Commands
This command installs the Weights and Biases library so you can use it in your Python projects.
Terminal
pip install wandb
Expected OutputExpected
Collecting wandb Downloading wandb-0.15.5-py3-none-any.whl (2.0 MB) Installing collected packages: wandb Successfully installed wandb-0.15.5
This command lets you log in to your Weights and Biases account from the command line so your data can be saved online.
Terminal
wandb login
Expected OutputExpected
wandb: Currently logged in as: example-user (use `wandb login --relogin` to force relogin)
--relogin - Force logging in again if you want to switch accounts
Run your training script that uses wandb to track metrics and save model information automatically.
Terminal
python train.py
Expected OutputExpected
wandb: Tracking run with ID abc123 wandb: Syncing metrics and model checkpoints Training complete: accuracy=0.92, loss=0.15
Key Concept

If you remember nothing else, remember: Weights and Biases automatically tracks and saves your machine learning experiments so you can see and compare results easily.

Code Example
MLOps
import wandb

wandb.init(project="example-project")

for epoch in range(3):
    accuracy = 0.8 + epoch * 0.05
    loss = 0.5 - epoch * 0.1
    wandb.log({"epoch": epoch, "accuracy": accuracy, "loss": loss})

print("Training simulation complete")
OutputSuccess
Common Mistakes
Not running 'wandb login' before starting training
Without logging in, your training data won't be saved to your online account.
Always run 'wandb login' once before running your training scripts.
Forgetting to add 'wandb.init()' in the training script
Weights and Biases won't start tracking your run without this initialization.
Add 'wandb.init(project="my-project")' at the start of your training code.
Summary
Install the wandb library to use Weights and Biases in your projects.
Log in once using 'wandb login' to connect your local machine to your online account.
Add wandb.init() and wandb.log() in your training code to track metrics automatically.