0
0
MLOpsdevops~10 mins

Random seed management in MLOps - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set a random seed in Python for reproducible results.

MLOps
import random
random.[1](42)
Drag options to blanks, or click blank then click option'
Arandint
Bshuffle
Cseed
Dchoice
Attempts:
3 left
💡 Hint
Common Mistakes
Using functions like randint or shuffle instead of seed.
2fill in blank
medium

Complete the code to set the seed for NumPy's random number generator.

MLOps
import numpy as np
np.random.[1](123)
Drag options to blanks, or click blank then click option'
Aseed
Brandom
Crand
Dchoice
Attempts:
3 left
💡 Hint
Common Mistakes
Using rand or random instead of seed.
3fill in blank
hard

Fix the error in setting the seed for PyTorch's random number generator.

MLOps
import torch
torch.[1](2024)
Drag options to blanks, or click blank then click option'
Aset_seed
Bmanual_seed
Crandom_seed
Dseed
Attempts:
3 left
💡 Hint
Common Mistakes
Using seed or set_seed which do not exist in PyTorch.
4fill in blank
hard

Fill both blanks to set seeds for Python's random and NumPy's random generators for reproducibility.

MLOps
import random
import numpy as np
random.[1](101)
np.random.[2](101)
Drag options to blanks, or click blank then click option'
Aseed
Brandint
Drandom
Attempts:
3 left
💡 Hint
Common Mistakes
Using randint or random instead of seed.
5fill in blank
hard

Fill all three blanks to set seeds for Python's random, NumPy's random, and PyTorch's random generators.

MLOps
import random
import numpy as np
import torch
random.[1](7)
np.random.[2](7)
torch.[3](7)
Drag options to blanks, or click blank then click option'
Aseed
Cmanual_seed
Drandint
Attempts:
3 left
💡 Hint
Common Mistakes
Using randint instead of seed or manual_seed.