Bird
Raised Fist0
MLOpsdevops~20 mins

Weights and Biases overview in MLOps - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
W&B Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the primary purpose of Weights and Biases (W&B)?

Choose the main function of Weights and Biases in machine learning projects.

ATo provide cloud storage for large datasets only.
BTo replace the need for writing machine learning code.
CTo track experiments, visualize results, and manage datasets.
DTo automatically generate machine learning models without user input.
Attempts:
2 left
💡 Hint

Think about tools that help you keep track of your work and results.

💻 Command Output
intermediate
1:00remaining
What output does the command 'wandb login' produce on success?

After running wandb login and entering a valid API key, what is the expected output?

MLOps
wandb login
ACommand not found: wandb
BSuccessfully logged in. You can now use W&B features.
CError: API key invalid. Please try again.
DNo output; the command runs silently.
Attempts:
2 left
💡 Hint

Successful login usually confirms with a message.

🔀 Workflow
advanced
1:30remaining
Which step correctly initializes a W&B run in Python?

Identify the correct code snippet to start tracking an experiment run with W&B in Python.

MLOps
import wandb

# Which line correctly initializes a run?
Awandb.init(project="my-project")
Bwandb.start(project="my-project")
Cwandb.run(project="my-project")
Dwandb.track(project="my-project")
Attempts:
2 left
💡 Hint

Look for the function that starts a new run session.

Troubleshoot
advanced
1:30remaining
What error occurs if you try to log metrics without initializing a W&B run?

Consider this code snippet:

import wandb
wandb.log({"accuracy": 0.9})

What error will this produce?

ANo error; metrics are logged automatically
Bwandb.errors.CommError: Run not initialized
CTypeError: log() missing required positional argument
DRuntimeError: You must call wandb.init() before wandb.log()
Attempts:
2 left
💡 Hint

Think about what must happen before logging metrics.

Best Practice
expert
2:00remaining
Which practice ensures reproducibility when using W&B in a team?

Choose the best practice to help a team reproduce machine learning experiments tracked with W&B.

ALog all hyperparameters, code versions, and environment details in W&B runs.
BAvoid using W&B and rely on manual notes.
CShare API keys openly in code for easy access.
DOnly log final accuracy metrics to reduce clutter.
Attempts:
2 left
💡 Hint

Think about what information helps others repeat your work exactly.

Practice

(1/5)
1. What is the main purpose of Weights and Biases (W&B) in machine learning?
easy
A. To deploy machine learning models to production automatically
B. To write machine learning algorithms from scratch
C. To replace the need for training data
D. To track experiments, log metrics, and visualize results

Solution

  1. Step 1: Understand W&B's role

    W&B is designed to help track experiments and log metrics during ML development.
  2. Step 2: Identify main features

    It provides visualization and comparison of results in a dashboard, not algorithm creation or deployment.
  3. Final Answer:

    To track experiments, log metrics, and visualize results -> Option D
  4. Quick Check:

    W&B tracks and visualizes experiments [OK]
Hint: Remember W&B is for tracking and visualizing experiments [OK]
Common Mistakes:
  • Confusing W&B with model deployment tools
  • Thinking W&B writes ML algorithms
  • Assuming W&B replaces training data
2. Which of the following is the correct command to initialize a W&B run in Python?
easy
A. wandb.init(project="my-project")
B. wandb.start(project="my-project")
C. wandb.run(project="my-project")
D. wandb.create(project="my-project")

Solution

  1. Step 1: Recall W&B initialization syntax

    The correct function to start a run is wandb.init() with project name as argument.
  2. Step 2: Check other options

    Functions like start(), run(), or create() do not exist in W&B API for initialization.
  3. Final Answer:

    wandb.init(project="my-project") -> Option A
  4. Quick Check:

    Use wandb.init() to start runs [OK]
Hint: Use wandb.init() to start tracking runs [OK]
Common Mistakes:
  • Using wandb.start() instead of wandb.init()
  • Confusing run() or create() as initialization methods
  • Missing the project argument
3. Given this Python snippet using W&B:
import wandb
wandb.init(project="test")
for epoch in range(2):
    wandb.log({"accuracy": 0.8 + 0.1 * epoch})

What will be the logged accuracy values after the loop?
medium
A. [0.9, 1.0]
B. [0.8, 0.9]
C. [0.8, 0.85]
D. [0.7, 0.8]

Solution

  1. Step 1: Analyze the loop iterations

    The loop runs for epoch = 0 and epoch = 1 (2 iterations).
  2. Step 2: Calculate logged accuracy values

    For epoch 0: 0.8 + 0.1*0 = 0.8; for epoch 1: 0.8 + 0.1*1 = 0.9.
  3. Final Answer:

    [0.8, 0.9] -> Option B
  4. Quick Check:

    Accuracy logged = [0.8, 0.9] [OK]
Hint: Calculate values for each epoch carefully [OK]
Common Mistakes:
  • Miscomputing the accuracy formula
  • Confusing loop range endpoints
  • Assuming only one iteration
4. You wrote this code snippet to log loss values with W&B but no data appears in the dashboard:
import wandb
wandb.init(project="demo")
for i in range(3):
    loss = 0.5 / (i+1)
    wandb.log(loss)

What is the error?
medium
A. wandb.log() requires a dictionary, not a single value
B. wandb.init() is missing the entity parameter
C. The loop range should start from 1, not 0
D. loss variable is not defined before wandb.log()

Solution

  1. Step 1: Check wandb.log() usage

    wandb.log() expects a dictionary with metric names as keys, not a single float value.
  2. Step 2: Identify correct logging format

    It should be wandb.log({"loss": loss}) to log the loss metric properly.
  3. Final Answer:

    wandb.log() requires a dictionary, not a single value -> Option A
  4. Quick Check:

    Always log metrics as dict in wandb.log() [OK]
Hint: Log metrics as dictionaries: wandb.log({"metric": value}) [OK]
Common Mistakes:
  • Passing a float directly to wandb.log()
  • Forgetting to name the metric in a dict
  • Assuming wandb.init() needs entity always
5. You want to compare two models' training runs side-by-side using W&B. Which approach best helps you achieve this?
hard
A. Use separate projects for each model and avoid comparing runs
B. Train models without logging and manually compare saved files
C. Log both models in the same project and use the W&B dashboard to compare runs
D. Log only the best model to reduce clutter

Solution

  1. Step 1: Understand W&B project and run organization

    Logging both models in the same project allows easy side-by-side comparison in the dashboard.
  2. Step 2: Evaluate other options

    Not logging or using separate projects makes comparison harder; logging only one model loses data.
  3. Final Answer:

    Log both models in the same project and use the W&B dashboard to compare runs -> Option C
  4. Quick Check:

    Same project logging enables run comparison [OK]
Hint: Use one project for related runs to compare easily [OK]
Common Mistakes:
  • Not logging runs for comparison
  • Using separate projects unnecessarily
  • Logging only one model run